-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(agent-core-v2): add hostIdentity domain for host-overridable system prompt identity #2144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
liruifengv
merged 4 commits into
MoonshotAI:main
from
sailist:feat/host-identity-system-prompt
Jul 27, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
786eca5
feat(agent-core-v2): add hostIdentity domain for host-overridable sys…
sailist 64edccb
chore: add changeset for host identity system prompt
sailist b554495
fix(agent-core-v2): adapt hostIdentity registration to ScopeActivation
sailist e1eadac
Merge remote-tracking branch 'origin/main' into pr-2144-host-identity
liruifengv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@moonshot-ai/agent-core-v2": patch | ||
| --- | ||
|
|
||
| Let embedding hosts customize the agent's product name and reply-style guidance in the system prompt when starting the server. |
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
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
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
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
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
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
56 changes: 56 additions & 0 deletions
56
packages/agent-core-v2/src/app/hostIdentity/hostIdentity.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /** | ||
| * `hostIdentity` domain (L3) — runtime identity of the embedding host. | ||
| * | ||
| * Holds process-level overrides the host product (CLI, desktop, …) injects at | ||
| * the composition root: `productName` fills the `${product_name}` slot in the | ||
| * base system-prompt template, `replyStyleGuide` replaces the | ||
| * `${reply_style_guide}` block (the CLI default describes Markdown rendering | ||
| * in a terminal). Composition roots set them through {@link hostIdentitySeed}; | ||
| * the registered default carries no overrides, so the template renders its CLI | ||
| * defaults. Bound at App scope. | ||
| */ | ||
|
|
||
| import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiation'; | ||
| import { LifecycleScope, registerScopedService, ScopeActivation, type ScopeSeed } from '#/_base/di/scope'; | ||
|
|
||
| export interface HostIdentityOverrides { | ||
| readonly productName?: string; | ||
| readonly replyStyleGuide?: string; | ||
| } | ||
|
|
||
| export interface IHostIdentity { | ||
| readonly _serviceBrand: undefined; | ||
| readonly productName?: string; | ||
| readonly replyStyleGuide?: string; | ||
| } | ||
|
|
||
| export const IHostIdentity: ServiceIdentifier<IHostIdentity> = | ||
| createDecorator<IHostIdentity>('hostIdentity'); | ||
|
|
||
| export class HostIdentity implements IHostIdentity { | ||
| declare readonly _serviceBrand: undefined; | ||
|
|
||
| constructor( | ||
| readonly productName?: string, | ||
| readonly replyStyleGuide?: string, | ||
| ) {} | ||
| } | ||
|
|
||
| export function hostIdentitySeed(overrides: HostIdentityOverrides | undefined): ScopeSeed { | ||
| if (overrides === undefined) return []; | ||
| if (overrides.productName === undefined && overrides.replyStyleGuide === undefined) return []; | ||
| return [ | ||
| [ | ||
| IHostIdentity as ServiceIdentifier<unknown>, | ||
| new HostIdentity(overrides.productName, overrides.replyStyleGuide), | ||
| ], | ||
| ]; | ||
| } | ||
|
|
||
| registerScopedService( | ||
| LifecycleScope.App, | ||
| IHostIdentity, | ||
| HostIdentity, | ||
| ScopeActivation.OnScopeCreated, | ||
| 'hostIdentity', | ||
| ); |
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the bundled
kimi webpath starts this server it does not passhostIdentity(checkedapps/kimi-code/src/cli/sub/web/run.ts:269-288), so this seed is empty andsystemPromptVarsfalls back to the CLI terminal wording. For browser-hosted sessions the model still receives terminal-specific reply guidance, defeating the new host override for an existing non-terminal host; pass a web/GUI identity from that start path or choose a non-terminal default when serving web assets.AGENTS.md reference: AGENTS.md:L18-L18
Useful? React with 👍 / 👎.