MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / resumePersistedAgent

Method resumePersistedAgent

packages/agent-core/src/session/index.ts:889–918  ·  view source on GitHub ↗
(
    id: string,
    stack: readonly string[] = [],
  )

Source from the content-addressed store, hash-verified

887 }
888
889 private async resumePersistedAgent(
890 id: string,
891 stack: readonly string[] = [],
892 ): Promise<ResumedAgent> {
893 await this.skillsReady;
894 const meta = this.metadata.agents[id];
895 if (meta === undefined) {
896 throw new KimiError(ErrorCodes.SESSION_STATE_INVALID, `Session agent "${id}" is missing`);
897 }
898
899 const parentAgentId = meta.parentAgentId ?? null;
900 const parent =
901 parentAgentId === null
902 ? undefined
903 : await this.resumeAgent(parentAgentId, [...stack, id]);
904
905 try {
906 const agent = this.instantiateAgent(id, meta.homedir, meta.type, {}, parentAgentId);
907 const result = await agent.resume();
908 this.restoreAgentProfileHandle(agent, meta, parent?.agent);
909 this.agents.set(id, agent);
910 return { agent, warning: parent?.warning ?? result.warning };
911 } catch (error) {
912 const entry = this.agents.get(id);
913 if (entry instanceof Promise) {
914 this.agents.delete(id);
915 }
916 throw error;
917 }
918 }
919
920 private restoreAgentProfileHandle(
921 agent: Agent,

Callers 1

resumeAgentMethod · 0.95

Calls 7

resumeAgentMethod · 0.95
instantiateAgentMethod · 0.95
setMethod · 0.65
getMethod · 0.65
deleteMethod · 0.65
resumeMethod · 0.45

Tested by

no test coverage detected