github / github/copilot-cli

When hit max_output_tokens, some events are not emitted and logged

Open
#4,733 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:sessions
Dominant language
Shell
Stars
11.2k
Forks
1.9k
Avg merge
14h 16m
Merged PRs (30d)
6

Description

Describe the bug

When the AI's output is truncated because it exceeds max_output_tokens and a subsequent request is made, both the current response and the next "continue" request are lost.

This happens in BYOK usage. I use the custom provider and it provides 65536 max_output_tokens. So it easily triggered this bug.

See this events.jsonl below (input and output is ommited for privacy):

Affected version

v1.0.83

Steps to reproduce the behavior

No response

Expected behavior

No response

Additional context
{"type":"session.start","data":{"sessionId":"summary-qq-group-957302634-1788584545","version":1,"producer":"copilot-agent","copilotVersion":"0.0.0","startTime":"2026-09-05T05:02:26.005Z","selectedModel":"deepseek-v4-flash","reasoningEffort":"high","contextTier":null,"context":{"cwd":"/home/cola/Softwares/kanade-bot"},"remoteSteerable":false,"alreadyInUse":false},"id":"3e23bf11-4b01-4b8a-bc43-ad9b7d007c69","timestamp":"2026-09-05T05:02:26.024Z","parentId":null}
{"type":"user.message","data":{"content":"...","transformedContent":"...","messageId":"33fe414d-6631-449a-a351-3a34b2c2b68d","supportedNativeDocumentMimeTypes":[],"delivery":"idle","interactionId":"9596a41f-2bfc-4191-998c-740b2e30caec","turnId":"0","parentAgentTaskId":"65b27352-d09e-4c72-956b-b69594366d8c"},"id":"f56f57fc-8c67-4bd2-a372-cfb61f2c4109","timestamp":"2026-09-05T05:02:29.423Z","parentId":"3e23bf11-4b01-4b8a-bc43-ad9b7d007c69"}
{"type":"system.message","data":{"role":"system","content":"...","interactionId":"9596a41f-2bfc-4191-998c-740b2e30caec"},"id":"a33407ed-4a7b-4feb-ad75-83d6b0eac50b","timestamp":"2026-09-05T05:02:29.445Z","parentId":"f56f57fc-8c67-4bd2-a372-cfb61f2c4109"}
{"type":"assistant.turn_start","data":{"turnId":"0","interactionId":"9596a41f-2bfc-4191-998c-740b2e30caec"},"id":"5583fe72-b633-44ea-a183-7ac781d075d2","timestamp":"2026-09-05T05:02:29.458Z","parentId":"a33407ed-4a7b-4feb-ad75-83d6b0eac50b"}
{"type":"assistant.turn_end","data":{"turnId":"0"},"id":"5df48ed1-fe69-4ffe-8645-f0fa2545ef14","timestamp":"2026-09-05T05:03:40.349Z","parentId":"5583fe72-b633-44ea-a183-7ac781d075d2"}
{"type":"assistant.turn_start","data":{"turnId":"1","interactionId":"9596a41f-2bfc-4191-998c-740b2e30caec"},"id":"53c4e5ae-2365-4391-86b3-c39735958279","timestamp":"2026-09-05T05:03:40.349Z","parentId":"5df48ed1-fe69-4ffe-8645-f0fa2545ef14"}
{"type":"assistant.turn_end","data":{"turnId":"1"},"id":"d48f14f2-263b-4990-8d66-f5e858a49b10","timestamp":"2026-09-05T05:04:51.913Z","parentId":"53c4e5ae-2365-4391-86b3-c39735958279"}
{"type":"assistant.turn_start","data":{"turnId":"2","interactionId":"9596a41f-2bfc-4191-998c-740b2e30caec"},"id":"e77c5372-08d4-47ba-b886-5a75ae6a5a6d","timestamp":"2026-09-05T05:04:51.914Z","parentId":"d48f14f2-263b-4990-8d66-f5e858a49b10"}
{"type":"assistant.message","data":{"messageId":"51f06be7-30d8-4d28-b8ae-e8dc1fcc9937","model":"deepseek-v4-flash","content":"(继续)...","toolRequests":[],"interactionId":"9596a41f-2bfc-4191-998c-740b2e30caec","turnId":"2","reasoningText":"Let me continue writing the topic summary. I was in the middle of topic 12. Let me continue from there, then complete the personal image section.","rte":false,"apiCallId":"6197b23f-7420-44dd-8bc4-a032e5784de2"},"id":"7fd35caa-4f74-4365-84d5-c39f7556561a","timestamp":"2026-09-05T05:05:41.237Z","parentId":"e77c5372-08d4-47ba-b886-5a75ae6a5a6d"}
{"type":"assistant.turn_end","data":{"turnId":"2"},"id":"1d7b9c22-2a37-4a73-b54e-f7f398c00f40","timestamp":"2026-09-05T05:05:41.244Z","parentId":"7fd35caa-4f74-4365-84d5-c39f7556561a"}
{"type":"session.shutdown","data":{"shutdownType":"routine","totalPremiumRequests":0,"totalNanoAiu":0,"totalApiDurationMs":190704,"sessionStartTime":1788584546005,"eventsFileSizeBytes":368878,"codeChanges":{"linesAdded":0,"linesRemoved":0,"filesModified":[]},"modelMetrics":{"deepseek-v4-flash":{"requests":{"count":3,"cost":0},"usage":{"inputTokens":234114,"outputTokens":21467,"cacheReadTokens":147456,"cacheWriteTokens":0,"reasoningTokens":14945},"totalNanoAiu":0}},"agentMetrics":{"main":{"totalApiDurationMs":190704,"totalNanoAiu":0.0,"modelMetrics":{"deepseek-v4-flash":{"requests":{"count":3,"cost":0.0},"usage":{"inputTokens":234114,"outputTokens":21467,"cacheReadTokens":147456,"cacheWriteTokens":0,"reasoningTokens":14945},"totalNanoAiu":0.0}}}},"currentModel":"deepseek-v4-flash","currentTokens":81090,"systemTokens":816,"conversationTokens":68907,"toolDefinitionsTokens":11364},"id":"391655ed-981c-4225-b84c-8948504c7bae","timestamp":"2026-09-05T05:05:41.537Z","parentId":"1d7b9c22-2a37-4a73-b54e-f7f398c00f40"}

OS: Linux Mint 22.3
Copilot SDK Version: v1.0.13

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file, test, or reproduction command is named. Start by tracing event emission and logging around max_output_tokens truncation in the Copilot CLI, then reproduce the provided custom-provider scenario and verify that both the truncated response and continuation request are emitted and logged.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.