Skip to content

Bug: delegate_task fails with 'Context length exceeded' for Ollama Cloud models (context_length overrides ignored) #44214

Description

@AlphaPerseii3000

Bug Description

When configuring delegate_task to use an Ollama Cloud model (e.g., qwen3-coder-next:cloud), every delegation attempt fails immediately with:

Context length exceeded (1,584 tokens). Cannot compress further.
  • Tokens consumed: input: 0, output: 0 — the model is never actually called
  • Direct API call (curl to https://ollama.com/v1/chat/completions) works perfectly with the same model
  • Known models (gpt-5.5 via openai-codex) work fine for delegation

Root Cause (suspected: #17685)

The delegation subsystem resolves the model's context length via a fallback mechanism. For non-catalogued Ollama Cloud models, it cannot read context_length overrides and falls back to a minimal safety value (~2,048 tokens). The delegation system prompt (~1,584 tokens) immediately exceeds this, triggering a fatal compression error before any API call.

Failed Workarounds

All of the following were tested and none resolved the issue:

  1. delegation.context_length: 64000 in config.yaml → ignored by delegate_task
  2. custom_providers block with model-level context_length override → ignored
  3. providers.ollama-cloud.models with context_length override → ignored
  4. context_length_cache.yaml forced to 64000 for the model key → ignored (cache gets overwritten back)
  5. Gateway restart after all config changes → same error persists

Reproduction

delegation:
  model: qwen3-coder-next:cloud
  provider: ollama-cloud
  base_url: https://ollama.com/v1

Then call delegate_task with any goal. Result: immediate failure.

Environment

  • Hermes Agent: latest (v0.8+)
  • Model: qwen3-coder-next:cloud (262,144 token context per Ollama)
  • Provider: ollama-cloud
  • OLLAMA_API_KEY: configured in .env
  • Direct curl to the API endpoint: works correctly

Expected Behavior

delegate_task should respect context_length overrides from any of the documented config paths (custom_providers, providers, delegation block, or cache) and successfully delegate to Ollama Cloud models.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointduplicateThis issue or pull request already existsprovider/ollamaOllama / local modelstool/delegateSubagent delegationtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions