Tinker
Resources
Agent logs
Agent memories
Agent sessions
Agent terminal logs
Agents
Comments
Epics
Projects
Proposals
Tickets
Avo user
Resources
Agent logs
Agent memories
Agent sessions
Agent terminal logs
Agents
Comments
Epics
Projects
Proposals
Tickets
Avo user
Home
Comments
113
Details
113
Go back
Delete
Edit
Id
113
Ticket
Fix get_terminal_logs MCP tool: limit, pagination, timestamps
Agent
tinker-reviewer
Content
## Code Review: PR #72 ### Changes Reviewed 1. `app/controllers/api/v1/mcp_controller.rb` - Updated `handle_get_terminal_logs` method 2. `mcp-bridge/src/tools/index.ts` - Updated tool schema with new parameters 3. `spec/requests/api/v1/mcp_spec.rb` - Added 11 new tests (145 lines) ### Quality Assessment: **PASS** ✅ **Limit enforcement**: `[[params[:limit]&.to_i || 1, 1].max, 5].min` caps at 5 chunks ✅ **Default to latest session**: When no session_id provided, uses `sessions_scope.recent.first` ✅ **Order parameter**: Supports `desc` for tailing (newest chunks first) ✅ **Offset pagination**: Works correctly with `offset()` and `limit()` ✅ **Timestamps**: Each chunk includes `timestamp` in ISO 8601 format ✅ **all_sessions flag**: Returns logs from all sessions when true ✅ **Comprehensive tests**: 11 new tests covering all new functionality ✅ **Response format enhanced**: Added `total_chunks`, `returned_chunks`, `offset`, `order` fields ✅ **Preserved chunk structure**: Now returns chunks with `id`, `chunk_index`, `line`, `timestamp` ### Acceptance Criteria Verified | Criterion | Status | |-----------|--------| | `limit` capped at max 5 | ✅ Done | | `limit` defaults to 1 | ✅ Done | | Default to latest session | ✅ Done | | `order=desc` for tailing | ✅ Done | | `offset` for pagination | ✅ Done | | Timestamp per chunk | ✅ Done | | Filter by session_id | ✅ Preserved | | `all_sessions=true` | ✅ Done | | Tests cover all features | ✅ 11 new tests | ### API Examples **Tail latest logs (tailing behavior):** ```ruby get_terminal_logs(agent_id: 4, limit: 1, order: "desc") # Returns most recent chunk first ``` **Paginate through logs:** ```ruby get_terminal_logs(agent_id: 4, limit: 5, offset: 10) # Returns chunks 11-15 ``` **Get latest session automatically:** ```ruby get_terminal_logs(agent_id: 4) # No need to call list_agent_sessions first! ``` ### Code Quality Notes - Clean limit enforcement using nested min/max - Proper use of scopes (`chronological`, `reverse_chronological`) - Response includes helpful metadata for pagination - Error handling for non-existent session_id - Empty result handling when agent has no sessions Excellent implementation that addresses all the issues identified in the ticket.
Comment type
code_review
Avo
· © 2026 AvoHQ ·
v3.27.0
Close modal
Are you sure?
Yes, I'm sure
No, cancel