()
| 596 | } |
| 597 | |
| 598 | async generateAgentsMd(): Promise<void> { |
| 599 | await this.skillsReady; |
| 600 | const mainAgent = this.requireMainAgent(); |
| 601 | |
| 602 | try { |
| 603 | const handle = await mainAgent.subagentHost!.spawn({ |
| 604 | profileName: 'coder', |
| 605 | parentToolCallId: 'generate-agents-md', |
| 606 | prompt: DEFAULT_INIT_PROMPT, |
| 607 | description: 'Initialize AGENTS.md', |
| 608 | runInBackground: false, |
| 609 | signal: new AbortController().signal, |
| 610 | }); |
| 611 | await handle.completion; |
| 612 | |
| 613 | const agentsMd = await loadAgentsMd(mainAgent.kaos, this.options.kimiHomeDir); |
| 614 | mainAgent.context.appendSystemReminder(initCompletionReminder(agentsMd), { |
| 615 | kind: 'injection', |
| 616 | variant: 'init', |
| 617 | }); |
| 618 | await mainAgent.records.flush(); |
| 619 | } catch (error) { |
| 620 | throw new KimiError( |
| 621 | ErrorCodes.SESSION_INIT_FAILED, |
| 622 | error instanceof Error ? error.message : 'Init failed', |
| 623 | { cause: error }, |
| 624 | ); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | /** |
| 629 | * Appends a fresh `<plugin_session_start>` system reminder to the main agent |
no test coverage detected