refactor: Unify streamId and conversationId handling for improved job management

- Updated ResumableAgentController and AgentController to generate conversationId upfront, ensuring it matches streamId for consistency.
- Simplified job creation and metadata management by removing redundant conversationId updates from callbacks.
- Refactored abortMiddleware and related methods to utilize the unified streamId/conversationId approach, enhancing clarity in job handling.
- Removed deprecated methods from GenerationJobManager and InMemoryJobStore, streamlining the codebase and improving maintainability.
This commit is contained in:
Danny Avila 2025-12-13 17:36:33 -05:00
parent 9a1e329f57
commit 11172895e8
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
6 changed files with 33 additions and 104 deletions

View file

@ -69,23 +69,6 @@ export class InMemoryJobStore implements IJobStore {
return this.jobs.get(streamId) ?? null;
}
async getJobByConversation(conversationId: string): Promise<SerializableJobData | null> {
// Direct match first (streamId === conversationId for existing conversations)
const directMatch = this.jobs.get(conversationId);
if (directMatch && directMatch.status === 'running') {
return directMatch;
}
// Search by conversationId in metadata
for (const job of this.jobs.values()) {
if (job.conversationId === conversationId && job.status === 'running') {
return job;
}
}
return null;
}
async updateJob(streamId: string, updates: Partial<SerializableJobData>): Promise<void> {
const job = this.jobs.get(streamId);
if (!job) {