Python agent runtime persists all inbound request headers, including Authorization, in session state

未关闭
#3,658 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@BahaaMattar 已经在做这个了。

开始于 2026年11月15日。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
postgresql, python, sqlite
领域
backend, security

调研方向

Start with python/packages/kagent-adk/src/kagent/adk/_agent_executor.py and trace how request headers enter run_request.state_delta on main. Check the header consumers named in the issue: types.py, _llm_passthrough_plugin.py, _remote_a2a_tool.py, and agentsts-adk's HEADERS_KEY; for 0.10.x also inspect KAgentSessionService.append_event in _session_service.py. Done means headers remain available during each invocation, including HITL resumes, while authorization values are absent from persisted session events and session state.

由索引模型根据 Issue 内容生成。

描述

Summary

The Python agent runtime (kagent-adk, the app image declarative Python agents run) stores the entire inbound A2A request header map, Authorization included, in the agent's session state. On 0.10.x that state goes to the controller's database, so every A2A call made with a bearer token leaves that token in the event table, where it outlives the request. It is also returned by the sessions events API to anyone who can read the session.

Go-runtime agents are not affected. We found no path from the stored headers into the model prompt unless an agent's system message templates {headers}.

Where

0.10.1 (also seen on release/v0.10.x head):

  • a2a-sdk a2a/server/apps/jsonrpc/jsonrpc_app.py: state['headers'] = dict(request.headers), which is every inbound header.
  • python/packages/kagent-adk/src/kagent/adk/_agent_executor.py: copies it into EventActions(state_delta={"headers": headers}) on a system event (invocation_id="header_update", author="system") and calls session_service.append_event.
  • _session_service.py KAgentSessionService.append_event: posts event.model_dump_json() to /api/sessions/{id}/events. The controller stores it in event.data.

main: the Postgres-backed session service is gone, but _agent_executor.py still sets run_request.state_delta = {"headers": headers}. So the full header map, credentials included, is kept in the in-process session (and in the sandbox runtime's SQLite session store).

Expected

Request headers are request-scoped. They're needed during the invocation (for allowedHeaders forwarding to MCP tools, token propagation to remote A2A agents, STS, LLM passthrough), but they should never be persisted. ADK's temp: state prefix gives exactly that: temp: keys are applied to the in-memory session for the current invocation and stripped from the event before any session service stores it. Storing the map under temp:headers (and reading it from there in the consumers: types.py header provider, _llm_passthrough_plugin.py, _remote_a2a_tool.py, agentsts-adk's HEADERS_KEY) keeps every consumer working. On 0.10.x KAgentSessionService posts before ADK trims the delta, so it would also need to apply and trim temp: keys before serializing.

Every request (including a HITL resume) sets the headers again, so nothing has to survive a turn.

Note for operators

Rows already written stay in the event table until they're removed. Deployments that ran Python agents on 0.10.x behind an authenticating gateway should check event.data for stored authorization headers.

主要语言
Go
星标
4.5k
派生
937
平均合并
1 天 10 小时
30 天内合并 PR
150

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

kagent-dev/kagent 的其他 Issue

查看 kagent-dev/kagent 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。