Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/user-prompt-hook-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@moonshot-ai/agent-core": patch
"@moonshot-ai/kimi-code": patch
---

Keep blocked prompt hook conversations available to subsequent model turns.
12 changes: 0 additions & 12 deletions apps/vis/web/src/components/wire/WireHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,6 @@ export function renderHeadline(r: AgentRecord): HeadlineRender {
),
};

case 'context.mark_last_user_prompt_blocked':
return {
main: (
<span className="flex items-center gap-2 min-w-0">
<Pill tone="warning" variant="soft">
blocked
</Pill>
<Dim>hook: {r.hookEvent}</Dim>
</span>
),
};

case 'context.clear':
return { main: <Dim>context cleared</Dim> };

Expand Down
2 changes: 0 additions & 2 deletions apps/vis/web/src/components/wire/typeMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const TYPE_TONE: Record<RecordType, PillTone> = {
'turn.cancel': 'warning',
'context.append_message': 'assistant',
'context.append_loop_event': 'meta',
'context.mark_last_user_prompt_blocked': 'warning',
'context.clear': 'warning',
'context.apply_compaction': 'compaction',
'tools.register_user_tool': 'tools',
Expand Down Expand Up @@ -40,7 +39,6 @@ export const TYPE_LABEL: Record<RecordType, string> = {
'turn.cancel': 'cancel',
'context.append_message': 'message',
'context.append_loop_event': 'loop',
'context.mark_last_user_prompt_blocked': 'blocked',
'context.clear': 'clear',
'context.apply_compaction': 'compacted',
'tools.register_user_tool': 'tool+',
Expand Down
16 changes: 0 additions & 16 deletions packages/agent-core/src/agent/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,6 @@ export class ContextMemory {
});
}

markLastUserPromptBlocked(hookEvent: string): void {
this.agent.records.logRecord({
type: 'context.mark_last_user_prompt_blocked',
hookEvent,
});
for (let i = this._history.length - 1; i >= 0; i--) {
const message = this._history[i];
if (message?.role !== 'user' || message.origin?.kind !== 'user') continue;
this._history[i] = {
...message,
origin: { ...message.origin, blockedByHook: hookEvent },
};
return;
}
}

clear(): void {
this.agent.records.logRecord({ type: 'context.clear' });
this._history = [];
Expand Down
1 change: 0 additions & 1 deletion packages/agent-core/src/agent/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { BackgroundTaskStatus } from '../../tools/background';

export interface UserPromptOrigin {
readonly kind: 'user';
readonly blockedByHook?: string | undefined;
}

export const USER_PROMPT_ORIGIN: UserPromptOrigin = { kind: 'user' };
Expand Down
3 changes: 0 additions & 3 deletions packages/agent-core/src/agent/records/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ function restoreAgentRecord(agent: Agent, input: AgentRecord): void {
case 'context.append_message':
agent.context.appendMessage(input.message);
return;
case 'context.mark_last_user_prompt_blocked':
agent.context.markLastUserPromptBlocked(input.hookEvent);
return;
case 'context.append_loop_event':
agent.context.appendLoopEvent(input.event);
return;
Expand Down
1 change: 0 additions & 1 deletion packages/agent-core/src/agent/records/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export interface AgentRecordEvents {
'full_compaction.complete': {};

'context.append_message': { message: ContextMessage };
'context.mark_last_user_prompt_blocked': { hookEvent: string };
'context.append_loop_event': { event: LoopRecordedEvent };
'context.clear': {};
'context.apply_compaction': CompactionResult;
Expand Down
1 change: 0 additions & 1 deletion packages/agent-core/src/agent/turn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ export class TurnFlow {
signal.throwIfAborted();
const blockResult = renderUserPromptHookBlockResult(promptHookResults);
if (blockResult !== undefined) {
this.agent.context.markLastUserPromptBlocked('UserPromptSubmit');
this.agent.context.appendMessage({
role: 'assistant',
content: [{ type: 'text', text: blockResult.text }],
Expand Down
1 change: 0 additions & 1 deletion packages/agent-core/test/agent/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ describe('Agent context', () => {
ctx.configure();

ctx.agent.context.appendUserMessage([{ type: 'text', text: 'blocked prompt' }]);
ctx.agent.context.markLastUserPromptBlocked('UserPromptSubmit');
ctx.agent.context.appendMessage({
role: 'assistant',
content: [
Expand Down
2 changes: 1 addition & 1 deletion packages/agent-core/test/agent/turn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ describe('Agent turn flow', () => {
role: 'user',
content: [{ type: 'text', text: 'bad words here' }],
toolCalls: [],
origin: { kind: 'user', blockedByHook: 'UserPromptSubmit' },
origin: { kind: 'user' },
},
{
role: 'assistant',
Expand Down
Loading