Skip to content
Open
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
4 changes: 4 additions & 0 deletions packages/agent-core-v2/src/agent/loop/turnEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export function turnPromptText(

export function isDisplayablePromptOrigin(origin: PromptOrigin): boolean {
if (origin.kind === 'user') return true;
// Goal continuations surface as a visible prompt bubble in chat UIs (like a
// cron fire), so the prompt text must travel with turn.started for the live
// view to render it — history already carries it on the persisted message.
Comment on lines +45 to +47

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove ordinary comments from the comment-free package

When the root pnpm lint runs, scripts/check-no-comments.mjs scans both packages/agent-core-v2/src and test and rejects these ordinary comments; the second newly added comment block at loop.test.ts:802-803 fails for the same reason. Remove both blocks or express the intent through naming.

AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L36-L39

Useful? React with 👍 / 👎.

if (origin.kind === 'system_trigger') return origin.name === 'goal_continuation';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent goal continuations from becoming searchable user prompts

When an automatic goal continuation occurs in a live session, this makes its long internal model instruction become TurnStarted.prompt; coreEventMap.ts:337-344 stores that as the transcript turn prompt, and searchService.ts:563-577 indexes every such prompt as a user message. Cold indexing deliberately excludes system_trigger messages (wireExtract.ts:72-76), so searches can return internal goal instructions while the session is live and then lose those hits after a cold rebuild. Keep the UI-only continuation text out of the searchable prompt field or filter this origin from live search indexing.

Useful? React with 👍 / 👎.

return (
(origin.kind === 'skill_activation' || origin.kind === 'plugin_command') &&
origin.trigger === 'user-slash'
Expand Down
25 changes: 21 additions & 4 deletions packages/agent-core-v2/test/agent/loop/loop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -758,15 +758,16 @@ describe('Agent loop', () => {
);
});

it('omits the turn.started prompt for system-triggered turns', async () => {
it('omits the turn.started prompt for system-triggered turns except goal continuations', async () => {
const prompts: Array<string | undefined> = [];
const subscription = ctx.get(IEventBus).subscribe(TurnStarted, (event) => {
prompts.push(event.prompt);
});
ctx.mockNextResponse({ type: 'text', text: 'continued' });
ctx.mockNextResponse({ type: 'text', text: 'subagent work' });
ctx.mockNextResponse({ type: 'text', text: 'hi there' });

const system = (
const goal = (
await loop.enqueue(
new MessageStepRequest(
{
Expand All @@ -779,12 +780,28 @@ describe('Agent loop', () => {
),
).assigned
).turn;
await system.result;
await goal.result;
const subagent = (
await loop.enqueue(
new MessageStepRequest(
{
role: 'user',
content: [{ type: 'text', text: 'subagent hidden prompt' }],
toolCalls: [],
origin: { kind: 'system_trigger', name: 'subagent' },
},
{ admission: 'newTurn' },
),
).assigned
).turn;
await subagent.result;
const user = (await loop.enqueue(nextTurnMessage('hi')).assigned).turn;
await user.result;
subscription.dispose();

expect(prompts).toEqual([undefined, 'hi']);
// Goal continuations carry their prompt (chat UIs render it as a visible
// bubble, like a cron fire); other system triggers stay hidden.
expect(prompts).toEqual(['continue the goal', undefined, 'hi']);
});
});

Expand Down
Loading