Skip to content

fix(adk): reject nil events from custom agents - #1245

Open
yiran-culture wants to merge 1 commit into
cloudwego:mainfrom
yiran-culture:codex/fix-agent-tool-nil-event
Open

fix(adk): reject nil events from custom agents#1245
yiran-culture wants to merge 1 commit into
cloudwego:mainfrom
yiran-culture:codex/fix-agent-tool-nil-event

Conversation

@yiran-culture

Copy link
Copy Markdown

What type of PR is this?

fix

Check the PR title.

  • This PR title matches the format: (optional scope):
  • The description is user-oriented and clear.
  • No user documentation update is required; this only replaces a recovered panic with a descriptive error for invalid custom-agent output.

(Optional) Translate the PR title into Chinese.

fix(adk): 拒绝自定义 Agent 返回的 nil 事件

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:

A custom Agent can currently send a nil event through its AsyncIterator. Both flowAgent.run and typedFlowAgent.run dereference that event while assigning RunPath, which triggers a nil-pointer panic. Although the outer recovery keeps the process alive, callers receive a generic panic error and stack trace instead of an actionable contract error.

This change validates events at the shared flow boundary for both Message and AgenticMessage paths. A nil event now terminates that run with a descriptive error containing the agent name. It also adds regression coverage for a nil event consumed directly through TypedRunner and through an AgentTool.

Validation:

  • go test ./adk/...
  • focused tests under go test -race
  • git diff --check

zh:

自定义 Agent 通过 AsyncIterator 返回 nil event 时,统一 flow 管线此前会在设置 RunPath 时发生空指针 panic。该修改在 Message 和 AgenticMessage 的公共边界进行校验,将 panic 转换为包含 Agent 名称的明确错误,并补充 Runner 与 AgentTool 回归测试。

(Optional) Which issue(s) this PR fixes:

Fixes #1244

(optional) The PR that updates user documentation:

Not required.

@CLAassistant

CLAassistant commented Sep 4, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@yiran-culture
yiran-culture force-pushed the codex/fix-agent-tool-nil-event branch from e15e6a6 to cfe00d4 Compare September 9, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

adk: nil event from custom agent is converted into panic error

2 participants