From 78876c51a625c2ea4809e3a331f3cc0d868a5102 Mon Sep 17 00:00:00 2001 From: os-zhuang Date: Wed, 10 Jun 2026 07:31:31 +0500 Subject: [PATCH] feat(service-ai): let the agent know when builds auto-publish (consistent narration) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The metadata agent couldn't see whether an environment auto-publishes AI builds, so it hedged ("staged for review / publish to make it live") even when a build had already gone live — contradicting the UI's "Published" state. buildSystemMessages now reads `context.autoPublishAiBuilds`: when the client reports auto-publish is on, the agent is told a finished whole-app build is live immediately and to say so (not "publish it to make it live"). Absent/false keeps the conservative framing. Pairs with the chat (objectui) passing the runtime flag in the chat context. - AgentChatContext: add `autoPublishAiBuilds?: boolean` - buildSystemMessages: append a "Publishing in this environment" note when on - tests: instruction present when on; silent when off/absent Co-Authored-By: Claude Opus 4.8 --- .../src/__tests__/chatbot-features.test.ts | 13 +++++++++++ .../services/service-ai/src/agent-runtime.ts | 22 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/packages/services/service-ai/src/__tests__/chatbot-features.test.ts b/packages/services/service-ai/src/__tests__/chatbot-features.test.ts index 90c61b248..e21dba19a 100644 --- a/packages/services/service-ai/src/__tests__/chatbot-features.test.ts +++ b/packages/services/service-ai/src/__tests__/chatbot-features.test.ts @@ -606,6 +606,19 @@ describe('AgentRuntime', () => { const messages = runtime.buildSystemMessages(DATA_CHAT_AGENT, {}); expect(messages[0].content).not.toContain('Current Context'); }); + + it('tells the agent builds are live when the environment auto-publishes', () => { + const messages = runtime.buildSystemMessages(DATA_CHAT_AGENT, { autoPublishAiBuilds: true }); + expect(messages[0].content).toContain('publish AUTOMATICALLY'); + expect(messages[0].content).toContain('is live'); + }); + + it('stays silent on publishing when auto-publish is off/absent', () => { + for (const ctx of [{}, { autoPublishAiBuilds: false }]) { + const messages = runtime.buildSystemMessages(DATA_CHAT_AGENT, ctx); + expect(messages[0].content).not.toContain('publish AUTOMATICALLY'); + } + }); }); describe('buildRequestOptions', () => { diff --git a/packages/services/service-ai/src/agent-runtime.ts b/packages/services/service-ai/src/agent-runtime.ts index 6ac2e1c1d..286f92dd6 100644 --- a/packages/services/service-ai/src/agent-runtime.ts +++ b/packages/services/service-ai/src/agent-runtime.ts @@ -28,6 +28,13 @@ export interface AgentChatContext extends SkillContext { recordId?: string; /** Current view name */ viewName?: string; + /** + * Whether this environment auto-publishes whole-app builds. When the client + * passes `true`, the agent is told a finished build is live immediately, so + * its narration matches reality ("your app is live") instead of defaulting to + * "publish it to make it live". Absent/false keeps the conservative framing. + */ + autoPublishAiBuilds?: boolean; } /** @@ -130,6 +137,21 @@ export class AgentRuntime { if (ctx.length > 0) { parts.push('\n--- Current Context ---\n' + ctx.join('\n')); } + // Environment publishing posture. When auto-publish is on, a finished + // whole-app build is already live, so the agent should say so rather than + // ask the user to publish. Authoring skills stay neutral by default (they + // can't see this runtime setting); this is what makes the narration match + // the UI's published state instead of hedging. + if (context.autoPublishAiBuilds === true) { + parts.push( + '\n--- Publishing in this environment ---\n' + + 'Whole-app builds publish AUTOMATICALLY here: the moment you finish building an app, ' + + 'it is live and ready to use — there is no manual publish step for the build. Tell the ' + + 'user their app is built and live (e.g. "your app is ready — open it from the launcher"). ' + + 'Do NOT tell them to "publish it to make it live" for a whole-app build. Smaller ' + + 'incremental edits are still staged for review — the chat panel shows each change\'s status.', + ); + } } // Active skill bundle