mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 14:01:06 +00:00
feat: defer session creation until first user+assistant message exchange
- Sessions are no longer created immediately on startup - Session files only created after at least 1 user message and 1 assistant response - Prevents empty session files when agent is launched and immediately quit - Messages are queued until session is initialized - Continue/resume modes properly mark sessions as already initialized
This commit is contained in:
parent
5e988b444b
commit
812f2f43cd
2 changed files with 55 additions and 6 deletions
|
|
@ -425,8 +425,8 @@ export async function main(args: string[]) {
|
|||
}
|
||||
}
|
||||
|
||||
// Start session
|
||||
sessionManager.startSession(agent.state);
|
||||
// Note: Session will be started lazily after first user+assistant message exchange
|
||||
// (unless continuing/resuming, in which case it's already initialized)
|
||||
|
||||
// Inject project context (AGENT.md/CLAUDE.md) if not continuing/resuming
|
||||
if (!parsed.continue && !parsed.resume) {
|
||||
|
|
@ -454,6 +454,11 @@ export async function main(args: string[]) {
|
|||
// Save messages on completion
|
||||
if (event.type === "message_end") {
|
||||
sessionManager.saveMessage(event.message);
|
||||
|
||||
// Check if we should initialize session now (after first user+assistant exchange)
|
||||
if (sessionManager.shouldInitializeSession(agent.state.messages)) {
|
||||
sessionManager.startSession(agent.state);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue