Is there any way to debug compaction/token usage/prompts? #2721

Open
opened 2026-02-16 17:36:57 -05:00 by yindo · 3 comments
Owner

Originally created by @oafx on GitHub (Nov 9, 2025).

Question

I feel like compaction is not working correctly currently.. i have 'limited' token budget (~130k) for my models and compaction runs like, every second message, even if it's just "wait a sec" and the agent returns "yeah sure" i see increases of token budgets by like 40k tokens.. then we'll spiral in auto compaction which only reduces the token usage down to like 90k.. and of course, if this wasn't strange enough, the compaction leads to pretty annoying memory loss/shift of objectives, which i can understand but it just feels off if it happens every few messages..

any hints on how to deliver more useful insights/bug reports to you guys? thanks!

Originally created by @oafx on GitHub (Nov 9, 2025). ### Question I feel like compaction is not working correctly currently.. i have 'limited' token budget (~130k) for my models and compaction runs like, every second message, even if it's just "wait a sec" and the agent returns "yeah sure" i see increases of token budgets by like 40k tokens.. then we'll spiral in auto compaction which only reduces the token usage down to like 90k.. and of course, if this wasn't strange enough, the compaction leads to pretty annoying memory loss/shift of objectives, which i can understand but it just feels off if it happens every few messages.. any hints on how to deliver more useful insights/bug reports to you guys? thanks!
Author
Owner

@Aureatus commented on GitHub (Nov 9, 2025):

In ~/.local/share/opencode/log you can find the opencode logs - by default the compaction logs don't have much info - just stuff like: INFO 2025-11-04T20:38:02 +0ms service=session.compaction pruning but per the docs - if you ran opencode with debug logging (opencode --log-level DEBUG) you might see more interesting info in there.

Other than that - can you share the opencode config you're using? (your repo level opencode.json and your global config at ~/.config/opencode/opencode.json

@Aureatus commented on GitHub (Nov 9, 2025): In `~/.local/share/opencode/log` you can find the opencode logs - by default the compaction logs don't have much info - just stuff like: `INFO 2025-11-04T20:38:02 +0ms service=session.compaction pruning` but per the [docs ](https://opencode.ai/docs/troubleshooting/#logs) - if you ran opencode with debug logging (opencode --log-level DEBUG) you might see more interesting info in there. Other than that - can you share the opencode config you're using? (your repo level opencode.json *and* your global config at `~/.config/opencode/opencode.json`
Author
Owner

@oafx commented on GitHub (Nov 9, 2025):

thanks! will give this a try. currently it looks like there haven't been any logs written for 2 days. in regards to your request, sure but it's pretty much standard, just tested the openai oauth codex plugin.. but i'm using primarily github copilot as agents

/* cat ~/.config/opencode/opencode.json */
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "opencode-openai-codex-auth"
  ],
  "provider": {
    "openai": {
      "options": {
        "reasoningEffort": "medium",
        "reasoningSummary": "auto",
        "textVerbosity": "medium",
        "include": [
          "reasoning.encrypted_content"
        ],
        "store": false
      },
      "models": {
        "gpt-5-codex-low": {
          "name": "GPT 5 Codex Low (OAuth)",
          "options": {
            "reasoningEffort": "low",
            "reasoningSummary": "auto",
            "textVerbosity": "medium",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        },
        "gpt-5-codex-medium": {
          "name": "GPT 5 Codex Medium (OAuth)",
          "options": {
            "reasoningEffort": "medium",
            "reasoningSummary": "auto",
            "textVerbosity": "medium",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        },
        "gpt-5-codex-high": {
          "name": "GPT 5 Codex High (OAuth)",
          "options": {
            "reasoningEffort": "high",
            "reasoningSummary": "detailed",
            "textVerbosity": "medium",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        },
        "gpt-5-minimal": {
          "name": "GPT 5 Minimal (OAuth)",
          "options": {
            "reasoningEffort": "minimal",
            "reasoningSummary": "auto",
            "textVerbosity": "low",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        },
        "gpt-5-low": {
          "name": "GPT 5 Low (OAuth)",
          "options": {
            "reasoningEffort": "low",
            "reasoningSummary": "auto",
            "textVerbosity": "low",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        },
        "gpt-5-medium": {
          "name": "GPT 5 Medium (OAuth)",
          "options": {
            "reasoningEffort": "medium",
            "reasoningSummary": "auto",
            "textVerbosity": "medium",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        },
        "gpt-5-high": {
          "name": "GPT 5 High (OAuth)",
          "options": {
            "reasoningEffort": "high",
            "reasoningSummary": "detailed",
            "textVerbosity": "high",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        },
        "gpt-5-mini": {
          "name": "GPT 5 Mini (OAuth)",
          "options": {
            "reasoningEffort": "low",
            "reasoningSummary": "auto",
            "textVerbosity": "low",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        },
        "gpt-5-nano": {
          "name": "GPT 5 Nano (OAuth)",
          "options": {
            "reasoningEffort": "minimal",
            "reasoningSummary": "auto",
            "textVerbosity": "low",
            "include": [
              "reasoning.encrypted_content"
            ],
            "store": false
          }
        }
      }
    }
  }
}

and no project specific opencode.json

@oafx commented on GitHub (Nov 9, 2025): thanks! will give this a try. currently it looks like there haven't been any logs written for 2 days. in regards to your request, sure but it's pretty much standard, just tested the openai oauth codex plugin.. but i'm using primarily github copilot as agents ```jsonc /* cat ~/.config/opencode/opencode.json */ { "$schema": "https://opencode.ai/config.json", "plugin": [ "opencode-openai-codex-auth" ], "provider": { "openai": { "options": { "reasoningEffort": "medium", "reasoningSummary": "auto", "textVerbosity": "medium", "include": [ "reasoning.encrypted_content" ], "store": false }, "models": { "gpt-5-codex-low": { "name": "GPT 5 Codex Low (OAuth)", "options": { "reasoningEffort": "low", "reasoningSummary": "auto", "textVerbosity": "medium", "include": [ "reasoning.encrypted_content" ], "store": false } }, "gpt-5-codex-medium": { "name": "GPT 5 Codex Medium (OAuth)", "options": { "reasoningEffort": "medium", "reasoningSummary": "auto", "textVerbosity": "medium", "include": [ "reasoning.encrypted_content" ], "store": false } }, "gpt-5-codex-high": { "name": "GPT 5 Codex High (OAuth)", "options": { "reasoningEffort": "high", "reasoningSummary": "detailed", "textVerbosity": "medium", "include": [ "reasoning.encrypted_content" ], "store": false } }, "gpt-5-minimal": { "name": "GPT 5 Minimal (OAuth)", "options": { "reasoningEffort": "minimal", "reasoningSummary": "auto", "textVerbosity": "low", "include": [ "reasoning.encrypted_content" ], "store": false } }, "gpt-5-low": { "name": "GPT 5 Low (OAuth)", "options": { "reasoningEffort": "low", "reasoningSummary": "auto", "textVerbosity": "low", "include": [ "reasoning.encrypted_content" ], "store": false } }, "gpt-5-medium": { "name": "GPT 5 Medium (OAuth)", "options": { "reasoningEffort": "medium", "reasoningSummary": "auto", "textVerbosity": "medium", "include": [ "reasoning.encrypted_content" ], "store": false } }, "gpt-5-high": { "name": "GPT 5 High (OAuth)", "options": { "reasoningEffort": "high", "reasoningSummary": "detailed", "textVerbosity": "high", "include": [ "reasoning.encrypted_content" ], "store": false } }, "gpt-5-mini": { "name": "GPT 5 Mini (OAuth)", "options": { "reasoningEffort": "low", "reasoningSummary": "auto", "textVerbosity": "low", "include": [ "reasoning.encrypted_content" ], "store": false } }, "gpt-5-nano": { "name": "GPT 5 Nano (OAuth)", "options": { "reasoningEffort": "minimal", "reasoningSummary": "auto", "textVerbosity": "low", "include": [ "reasoning.encrypted_content" ], "store": false } } } } } } ``` and no project specific opencode.json
Author
Owner

@rekram1-node commented on GitHub (Nov 9, 2025):

@oafx u can export any session to json:

opencode export > out.json (if u dont redirect then it goes to stdout)

It will open a list to select a session from

@rekram1-node commented on GitHub (Nov 9, 2025): @oafx u can export any session to json: `opencode export > out.json` (if u dont redirect then it goes to stdout) It will open a list to select a session from
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2721