kongxin 53c5195e5d
fix(gateway): name the agent problem when run admission rejects agent_name (#8087)
* fix(gateway): name the agent problem when run admission rejects agent_name

Since #5238, run admission loads the named custom agent's config for
every run, with or without a knowledge scope, and folded every failure
into "knowledge_scope assistant configuration could not be resolved".
Messaging a chat whose custom agent was deleted, or passing a malformed
agent_name, pointed callers at the knowledge base instead of the agent.

The 422 status is unchanged; the detail now says which problem it is:
- Agent '<name>' not found
- Invalid agent_name '<value>': must contain only letters, digits, and
  hyphens after normalization. (shared with custom_agent_name(), which
  gains a field= argument; existing callers keep the default)
- Invalid agent_name: expected a string, got <type>.
- Agent '<name>' configuration could not be loaded

* docs(changelog): reference #8087 for the run admission agent_name detail

* fix(gateway): bound the agent name echoed in run admission errors

Address review on #8087: admission now echoes the caller's raw
agent_name, which start_run merges from config/context without a size
check, so an oversized value was reflected verbatim into the 422 detail
and any log line that records it. Cap the echoed name at 200 characters
in the invalid-name message (shared with assistant_id validation) and in
the not-found / unreadable-config messages.

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-12 19:34:10 +08:00
..