fix(app): bind ambient chat to the platform ask agent - #607
Merged
Conversation
`crm_enterprise` still declared `defaultAgent: 'sales_copilot'`, an app-authored agent retired in #512. Per ADR-0063 §1/§2 `defaultAgent` is a surface binding, not a custom-agent slot: the only resolvable values are the two platform agents (`ask` for data surfaces, `build` for authoring surfaces), so `loadAgent()` refused the record and the floating chatbot resolved to nothing. Nothing caught it — `App.defaultAgent` is typed `SnakeCaseIdentifierSchema`, so any well-formed snake_case name parses, and the platform's agent lint only walks `stack.agents`. Adds a guard to `test/metadata-references.test.ts` pinning every app's `defaultAgent` against the platform agent set, read off the spec's own `AgentSchema.shape.surface` rather than transcribed, so the set tracks the contract instead of drifting from it. Also clears the stale `sales_copilot` mention in the `account_detail` page comment. Fixes #586 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019SS7C5SXpniKeCApxgARyf
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
os-zhuang
marked this pull request as ready for review
August 2, 2026 11:13
This was referenced Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #586
Description
crm_enterprise仍然声明defaultAgent: 'sales_copilot'—— 这个 app 自建 agent 早在 #512 就随「skills-only surface」(ADR-0063 §2)一起退役了。按 ADR-0063 §1/§2,
defaultAgent是一个 surface 绑定,不是自定义 agent 的插槽:可解析的取值只有两个平台 agent ——ask(数据面,隐式默认)与build(Studio 这类编排面)。运行时loadAgent()会拒绝非平台记录,所以这条绑定是死元数据:app-shell 挂载的悬浮 chatbot 解析不到 agent。为什么没人发现:
App.defaultAgent的类型是SnakeCaseIdentifierSchema,任何合法 snake_case 都能通过校验;而平台的 agent authoring lint 只遍历stack.agents,从不看app.defaultAgent。于是os validate、pnpm build、pnpm lint全绿,缺陷一直沉默到 demo 现场才暴露。HotCRM 是数据面,因此绑定
ask。app 自身的 AI 能力以 skills 形式交付(src/skills/,共 6 个),它们本来就通过surface亲和挂到平台 agent 上 —— 修好绑定后助手即可带着完整技能集回答。Type of Change
Related Issues
Fixes #586
Related to #512
Changes Made
src/apps/crm.app.ts—defaultAgent: 'sales_copilot'→'ask',并补注释说明这是 surface 绑定而非自定义 agent 插槽(避免下一个作者再填一个"业务味"的名字)。src/pages/account_detail.page.ts— 清理注释里同样过期的sales_copilot引用。test/metadata-references.test.ts— 新增app AI bindings resolve to a platform agent守卫(3 条断言)。.changeset/app-default-agent-platform-binding.md— patch。守卫为什么这样写
平台 agent 集合从 spec 自身读出,不在测试里再抄一份:
agent 名与 surface 名是同两个 token(
AgentSchema.surface即z.enum(['ask','build'])),所以这个集合跟着契约走,不会随平台演进而在 app 侧腐化。这是刻意的 contract-first 选择:与其在消费侧写宽容回退,不如让约束在写元数据时就咬人。三条断言:
the spec still exposes exactly the two platform agents—— guard the guard,内省一旦返回[],下面的检查会变成空断言而假绿。every app defaultAgent names a platform agent—— 本 issue 的核心。缺省 key 是合法的(ask是隐式默认),只校验显式取值。the app authors no agents of its own—— ADR-0063 §2。重新引入 app agent 正是让sales_copilot这类名字"看起来合理"的前提;同时断言 skills 非空,避免这条退化成永真。Testing
pnpm test)pnpm lint)pnpm build)反向验证(证明守卫真的会咬,而不是恰好全绿):把
defaultAgent临时改回'sales_copilot'后单跑该用例 ——改回
'ask'后恢复绿色。Checklist
Additional Notes
范围外发现,已另行开单 #606:
sales_copilot在src/之外还有 4 处存活引用 ——scripts/wow1-live-schema.sh:82与三个语种的content/docs/ai-copilot/live-schema*.mdx,都是 Wow #1 demo 里POST /api/v1/ai/chat的请求体。那不是过期注释而是会真的失败的可执行路径(脚本用curl -fsS,第二步直接中止)。本 PR 未改动它们,因为 #586 的验收明确限定在src/。#606 里也一并记了objectstack.config.ts:76那句「the two agents + skills」的过期注释。上游缺口(属 objectstack 侧,本 PR 不涉及):agent authoring lint 只走
stack.agents,不校验app.defaultAgent的引用完整性。本 PR 的守卫是 app 侧的补位,不应替代上游修复。🤖 Generated with Claude Code
https://claude.ai/code/session_019SS7C5SXpniKeCApxgARyf
Generated by Claude Code