Add continuation field to logs JSON output when timeout is reached #2064
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When the
logscommand times out before fetching all available workflow runs, agents using the MCP server have no way to know that more data is available or how to continue fetching from where the timeout occurred. This makes it difficult for agents to retrieve complete log data when working with large repositories.Solution
This PR adds a
continuationfield to the JSON output of thelogscommand that appears when a timeout occurs. The continuation field provides all necessary parameters for agents to seamlessly continue fetching logs from where the previous request stopped.Changes
New
ContinuationDatastruct (pkg/cli/logs_report.go)message,workflow_name,count,start_date,end_date,engine,branch,after_run_id,before_run_id,timeoutomitemptytag)Enhanced timeout handling (
pkg/cli/logs.go)before_run_idto the oldest processed run ID for proper paginationUpdated MCP server documentation (
pkg/cli/mcp_server.go)Comprehensive test coverage (
pkg/cli/logs_json_test.go)Example Output
With timeout (continuation present):
{ "summary": { "total_runs": 5, ... }, "runs": [ ... ], "continuation": { "message": "Timeout reached. Use these parameters to continue fetching more logs.", "workflow_name": "weekly-research", "count": 100, "before_run_id": 12341, "timeout": 50 } }Without timeout (continuation omitted):
{ "summary": { "total_runs": 100, ... }, "runs": [ ... ] }Usage Pattern
Agents can now implement a simple pattern to fetch all logs:
continuationfieldbefore_run_idfrom continuationThis enables agents to efficiently retrieve complete log data regardless of repository size or network conditions.
Benefits
Fixes the issue where agents had no way to detect or handle incomplete log data due to timeouts.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.