Skip to content

LLM-24890 Generate a chat name based on the first message#52

Open
NikolaiSviridov wants to merge 1 commit intomainfrom
nikolaisv/main/LLM-24890-Codex-ACP]-Generate-a-chat-name-based-on-the-first-message
Open

LLM-24890 Generate a chat name based on the first message#52
NikolaiSviridov wants to merge 1 commit intomainfrom
nikolaisv/main/LLM-24890-Codex-ACP]-Generate-a-chat-name-based-on-the-first-message

Conversation

@NikolaiSviridov
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/CodexEventHandler.ts
}
}

private extractNotificationThreadId(notification: ServerNotification): string | null {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why we need this unsafe method?
App-server listener should already be session-scoped.
Plus we can take threadId directly if we pass specific type after switch-case.

Comment thread src/CodexAcpServer.ts
rateLimits: RateLimitsMap | null;
account: Account | null;
cwd: string;
threadRenameState: "notScheduled" | "running" | "done";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we simplify the state here? Ideally we don't save it and on first prompt check if it's a first user prompt and schedule rename if it is.
In worst case we can introduce this flag instead of rename state.

Comment thread src/CodexAcpServer.ts
private scheduleThreadRenameFromContext(
sessionState: SessionState,
modelId: ModelId,
summary: "none" | null,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we can always disable streaming reasoning for thread naming process?
Do they stream this reasoning in CLI?

ModelId is already defined in the sessionState, why we need to duplicate?

resolve(event);
});
});
async awaitTurnCompletedForThread(threadId: string, turnId: string | null = null): Promise<TurnCompletedNotification> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you really need to wait for specific turn? You can't have multiple running turns in the same session.
Also to me it's enough to add threadId as parameter, no need to duplicate it in the name.
awaitTurnCompleted(threadId)

}
}

private handleTurnCompleted(event: TurnCompletedNotification): void {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why we need all these methods?

@@ -265,9 +264,9 @@ describe('ACP server test', { timeout: 40_000 }, () => {

// Trigger notifications after both prompts - should produce only 3 events, not 6
const serverNotifications: ServerNotification[] = [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why we renamed it and introduced parameter for the function loadNotifications? As far as I can see it only have single usage.

Comment thread src/CodexAcpClient.ts
});
forkedThreadId = fork.thread.id;

const started = await this.codexClient.turnStart({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this approach copied from VS Code implementation including prompt text?
I would expect official API from the app-server, we can ask about this codex team.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is possible an ACP agent does not support thread name providing. For that case we can fallback to some AIA logic which will be written and tested inside AIA chat and will be common for all agents.

I also don't think we hgave to write such business logic in the adapter with custom promts, models, params, etc

Comment thread src/CodexAcpClient.ts
return await this.codexClient.awaitTurnCompleted();
// Wait for completion of the specific started turn.
// If turnInterrupt() was called, Codex will send turn/completed with status "interrupted".
return await this.codexClient.awaitTurnCompletedForThread(request.sessionId, started?.turn?.id ?? null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it seems it is a valid fix and it should be merged even withpout the feature itself. but worth an additional test which reproduces possible issue with previous versions without specific thread id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants