Skip to content

[BUG] Asking broad questions result in prompt too long. #1877

@marcofranssen

Description

@marcofranssen

📋 Prerequisites

  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow our Code of Conduct
  • I am using the latest version of the software
  • I have tried to clear cache/cookies or used incognito mode (if ui-related)
  • I can consistently reproduce this issue

🎯 Affected Service(s)

Not Sure

🚦 Impact/Severity

Minor inconvenience

🐛 Bug Description

Running with Claude Sonnet 4.6 on Bedrock I'm getting following quite easily.

🔄 Steps To Reproduce

E.g.:

  1. Ask the k8s-agent to make suggestions on improving the deployments in a namespace.
  2. after calling couple of tools it fails with following

Any broad question will make it fail…

🤔 Expected Behavior

Proper compaction happens to ensure the tool outputs and such are compacted to make proper requests to the LLM.

📱 Actual Behavior

LLM error: API_ERROR operation error Bedrock Runtime: Converse, https response error StatusCode: 400, RequestID: 59c80fdf-4b8e-4d50-ac1b-d3b6188c8d58, ValidationException: The model returned the following errors: prompt is too long: 1580999 tokens > 1000000 maximum```

### 💻 Environment

Installed 0.9.4 helm chart.

### 🔧 CLI Bug Report

_No response_

### 🔍 Additional Context

Sonnet 4.6 Bedrock

### 📋 Logs

```shell
{"level":"info","timestamp":"2026-05-15T18:49:39.659Z","caller":"cmd/main.go:53","msg":"Logger initialized","level":"info"}
{"level":"info","timestamp":"2026-05-15T18:49:39.665Z","caller":"cmd/main.go:89","msg":"Loaded agent config","configDir":"/config"}
{"level":"info","timestamp":"2026-05-15T18:49:39.665Z","caller":"cmd/main.go:90","msg":"Agent configuration","model":"bedrock","stream":false,"httpTools":1,"sseTools":0,"remoteAgents":0}
{"level":"info","timestamp":"2026-05-15T18:49:39.665Z","caller":"cmd/main.go:234","msg":"Built app_name from environment variables","KAGENT_NAMESPACE":"kagent","KAGENT_NAME":"k8s-agent","app_name":"kagent__NS__k8s_agent"}
{"level":"info","timestamp":"2026-05-15T18:49:39.680Z","caller":"cmd/main.go:125","msg":"ADK telemetry initialized"}
{"level":"info","timestamp":"2026-05-15T18:49:39.680Z","caller":"cmd/main.go:140","msg":"Token service started"}
{"level":"info","timestamp":"2026-05-15T18:49:39.680Z","caller":"cmd/main.go:151","msg":"Using KAgent session service","url":"http://kagent-controller.kagent:8083"}
{"level":"info","timestamp":"2026-05-15T18:49:39.680Z","caller":"cmd/main.go:173","msg":"Memory service enabled","appName":"kagent__NS__k8s_agent"}
{"level":"info","timestamp":"2026-05-15T18:49:39.681Z","caller":"mcp/registry.go:86","msg":"Processing HTTP MCP tools","httpToolsCount":1}
{"level":"info","timestamp":"2026-05-15T18:49:39.681Z","caller":"mcp/registry.go:143","msg":"Adding HTTP MCP tool","index":1,"url":"http://kagent-tools.kagent:8084/mcp","toolFilterCount":18,"tools":["k8s_check_service_connectivity","k8s_patch_resource","k8s_remove_annotation","k8s_annotate_resource","k8s_remove_label","k8s_label_resource","k8s_create_resource","k8s_create_resource_from_url","k8s_get_events","k8s_get_available_api_resources","k8s_get_cluster_configuration","k8s_describe_resource","k8s_delete_resource","k8s_get_resource_yaml","k8s_execute_command","k8s_apply_manifest","k8s_get_resources","k8s_get_pod_logs"]}
{"level":"info","timestamp":"2026-05-15T18:49:39.681Z","caller":"mcp/registry.go:153","msg":"Successfully added HTTP MCP toolset","url":"http://kagent-tools.kagent:8084/mcp"}
{"level":"info","timestamp":"2026-05-15T18:49:39.681Z","caller":"mcp/registry.go:107","msg":"Processing SSE MCP tools","sseToolsCount":0}
{"level":"info","timestamp":"2026-05-15T18:49:39.681Z","caller":"agent/agent.go:154","msg":"Memory configuration detected, adding memory tools"}
{"level":"info","timestamp":"2026-05-15T18:49:39.716Z","caller":"models/bedrock.go:128","msg":"Initialized Bedrock Converse API model","model":"us.anthropic.claude-sonnet-4-6","region":"us-east-1"}
{"level":"info","timestamp":"2026-05-15T18:49:39.718Z","caller":"agent/agent.go:132","msg":"Creating Google ADK LLM agent","name":"k8s_agent","hasDescription":true,"hasInstruction":true,"toolsCount":4,"toolsetsCount":1}
{"level":"info","timestamp":"2026-05-15T18:49:39.718Z","caller":"agent/agent.go:144","msg":"Successfully created Google ADK LLM agent","toolsCount":4,"toolsetsCount":1}
{"level":"info","timestamp":"2026-05-15T18:49:39.719Z","caller":"app/app.go:114","msg":"Using KAgent session service","url":"http://kagent-controller.kagent:8083"}
{"level":"info","timestamp":"2026-05-15T18:49:39.719Z","caller":"app/app.go:118","msg":"Using KAgent task store","url":"http://kagent-controller.kagent:8083"}
{"level":"info","timestamp":"2026-05-15T18:49:39.722Z","caller":"server/server.go:78","msg":"Starting Go ADK server!","addr":"0.0.0.0:8080"}
{"level":"info","timestamp":"2026-05-15T18:50:11.849Z","logger":"kagent-executor","caller":"a2a/executor.go:123","msg":"Execute","taskID":"019e2cf9-8a09-74ff-bf8b-663e0be2043d","contextID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","appName":"kagent__NS__k8s_agent","userID":"372463714525255869"}
{"level":"info","timestamp":"2026-05-15T18:50:20.092Z","caller":"agent/agent.go:362","msg":"Tool execution started","tool":"load_memory","functionCallID":"tooluse_qyHunzcRvwjoEXXvwhpaJs","sessionID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","invocationID":"e-f59e5329-3210-47f0-9749-711bf18dcbb0","args":"{\"query\":\"cluster configuration preferences kubernetes best practices\"}"}
{"level":"info","timestamp":"2026-05-15T18:50:20.294Z","caller":"agent/agent.go:384","msg":"Tool execution completed","tool":"load_memory","functionCallID":"tooluse_qyHunzcRvwjoEXXvwhpaJs","sessionID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","invocationID":"e-f59e5329-3210-47f0-9749-711bf18dcbb0","resultKeys":["memories"]}
{"level":"info","timestamp":"2026-05-15T18:50:29.753Z","caller":"agent/agent.go:362","msg":"Tool execution started","tool":"k8s_get_resources","functionCallID":"tooluse_4iKxf4190ia92ErFp5D7ls","sessionID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","invocationID":"e-f59e5329-3210-47f0-9749-711bf18dcbb0","args":"{\"all_namespaces\":\"true\",\"output\":\"json\",\"resource_type\":\"daemonsets\"}"}
{"level":"info","timestamp":"2026-05-15T18:50:29.754Z","caller":"agent/agent.go:362","msg":"Tool execution started","tool":"k8s_get_resources","functionCallID":"tooluse_2Dgujd9VMLkxNsKk0Jf1MQ","sessionID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","invocationID":"e-f59e5329-3210-47f0-9749-711bf18dcbb0","args":"{\"all_namespaces\":\"true\",\"output\":\"json\",\"resource_type\":\"pods\"}"}
{"level":"info","timestamp":"2026-05-15T18:50:29.754Z","caller":"agent/agent.go:362","msg":"Tool execution started","tool":"k8s_get_resources","functionCallID":"tooluse_bJMM5ugkE282XsjiO8sXYJ","sessionID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","invocationID":"e-f59e5329-3210-47f0-9749-711bf18dcbb0","args":"{\"all_namespaces\":\"true\",\"output\":\"json\",\"resource_type\":\"deployments\"}"}
{"level":"info","timestamp":"2026-05-15T18:50:30.202Z","caller":"agent/agent.go:384","msg":"Tool execution completed","tool":"k8s_get_resources","functionCallID":"tooluse_4iKxf4190ia92ErFp5D7ls","sessionID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","invocationID":"e-f59e5329-3210-47f0-9749-711bf18dcbb0","resultKeys":["output"]}
{"level":"info","timestamp":"2026-05-15T18:50:30.673Z","caller":"agent/agent.go:384","msg":"Tool execution completed","tool":"k8s_get_resources","functionCallID":"tooluse_bJMM5ugkE282XsjiO8sXYJ","sessionID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","invocationID":"e-f59e5329-3210-47f0-9749-711bf18dcbb0","resultKeys":["output"]}
{"level":"info","timestamp":"2026-05-15T18:50:31.232Z","caller":"agent/agent.go:384","msg":"Tool execution completed","tool":"k8s_get_resources","functionCallID":"tooluse_2Dgujd9VMLkxNsKk0Jf1MQ","sessionID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","invocationID":"e-f59e5329-3210-47f0-9749-711bf18dcbb0","resultKeys":["output"]}
2026/05/15 18:50:32 ERROR failed to write an event error="write tcp 10.6.9.53:8080->10.6.9.61:56982: write: broken pipe"
2026/05/15 18:50:34 traces export: rpc error: code = ResourceExhausted desc = grpc: received message larger than max (9950241 vs. 4194304)
{"level":"info","timestamp":"2026-05-15T18:57:05.652Z","logger":"kagent-executor","caller":"a2a/executor.go:123","msg":"Execute","taskID":"019e2cff-da74-7cd8-8dd8-f54cf68d7319","contextID":"ctx-0dd7dd48-f281-4395-9dbc-04138b15cbeb","appName":"kagent__NS__k8s_agent","userID":"372463714525255869"}

📷 Screenshots

Image

🙋 Are you willing to contribute?

  • I am willing to submit a PR to fix this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions