Skip to content

[FEATURE] Reduce initial system prompt token overhead (~68k tokens before first user message) #26661

Closed as duplicate

Description

@wdsAI-space

Problem

In a fresh OpenCode session with a standard setup (Sisyphus agent, ~100 skills, 50+ tools), the token count before the user sends a single message is approximately 68,000 tokens. This is ~99% system overhead.

Breakdown:

  • Skill descriptions: 100+ skills with full descriptions inlined in system prompt
  • Tool JSON Schemas: 50+ tool definitions (Playwright, AST, Spec-workflow, etc.)
  • Agent behavior instructions: Full Phase 0-3 orchestration rules
  • Using-superpowers skill: Injected inline at session start

For comparison, Claude Code's system prompt is ~10-15k tokens for the first message.

Impact

With a typical 128k context window:

  • Effective conversation space: ~60k tokens (less than half the window)
  • Faster context exhaustion → more frequent compressions → potential loss of context
  • Higher API costs per conversation turn (system prompt sent every time)
  • Shorter productive sessions before hitting context limits

Proposed Solutions

1. Lazy-load skill descriptions

Currently all 100+ skill names + descriptions are inlined. Only inject skill names initially, and load full descriptions on-demand when skill tool is invoked. This could save ~10-15k tokens.

2. Tool schema compression

  • Only inline tool schemas for tools the current agent type is likely to use
  • Or use abbreviated schemas with a "full schema on demand" mechanism
  • Some tools (e.g., full Playwright suite with 20+ methods) are rarely all used in one session

3. Agent instruction modularization

The Sisyphus Phase 0-3 behavior instructions are verbose. Consider:

  • Loading detailed instructions only when the agent type is Sisyphus
  • Providing a compressed version for simpler agent types (Sisyphus-Junior, explore, etc.)
  • Subagents already have scoped instructions; the orchestrator pays the full cost

4. Skill content injection optimization

The using-superpowers skill content is injected with <EXTREMELY_IMPORTANT> tags at session start. Consider deferring this until a skill is actually matched/needed.

Related Issues

Environment

  • OpenCode v1.14.45
  • Windows 11
  • Agent: Sisyphus with ~100 installed skills

Activity

  1. github-actions commented on May 10, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review these issues to see if your request is already covered or can be addressed there. If you believe this is distinct, feel free to clarify how it differs.

  2. sanjeev23oct commented on Jun 17, 2026

    @sanjeev23oct

    ZAP takes the opposite approach to this — skills lazy-load and only
    inject when keywords match your message, MCP schemas stay out of
    context until the model explicitly connects them. Base overhead for
    a greeting is ~31 tokens.

    Might be worth a look if the overhead here is a blocker:
    https://github.com/zap-coding-agent/zap-coding-agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions