fix: persist session model/permissions in metadata for restore#129
fix: persist session model/permissions in metadata for restore#129AgentWrapper wants to merge 3 commits intomainfrom
Conversation
…rite The session-manager already writes model, permissions, and restoredAt to metadata during spawn() and restore(), but writeMetadata() and readMetadata() silently dropped these fields during serialization. This caused session.metadata?.["model"] and session.metadata?.["permissions"] to always be undefined when reading back from disk, preventing restored sessions from preserving their original agent configuration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When restoring a session, prefer the permissions and model values saved in session metadata (persisted at spawn time) over the current project config. This ensures restored sessions use the same configuration they were originally spawned with, even if the project config has changed. The fallback to project.agentConfig covers older sessions that were spawned before metadata persistence was added. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Agent plugins depend on built type definitions from @composio/ao-core. Without building core first, pnpm -r typecheck runs all checks in parallel and agent plugins fail with TS2353 errors (e.g. getActivityState not found in Agent interface) because the .d.ts files don't exist yet. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| // Check model: prefer metadata (persisted at spawn time), fall back to project config | ||
| const model = session.metadata?.["model"] ?? project.agentConfig?.model; | ||
| if (model) { | ||
| parts.push("--model", shellEscape(model as string)); |
There was a problem hiding this comment.
Metadata values never written, restore fix is no-op
High Severity
getRestoreCommand now prefers session.metadata?.["permissions"] and session.metadata?.["model"] over project config, but no code path in the codebase ever writes these fields to the metadata file. The spawn function in session-manager.ts has permissions and model available in agentLaunchConfig but omits them from its writeMetadata call. The metadata lookup always returns undefined, so the fallback to project.agentConfig always triggers — making this change a no-op and the "stale config" fix ineffective.


Summary
Fixes metadata serialization gaps in the session restore pipeline. Three issues addressed:
Metadata fields silently dropped:
writeMetadata()andreadMetadata()didn't serializemodel,permissions, orrestoredAtfields, even thoughSessionMetadatadefined them andsession-manager.tswrote them. Values were silently discarded.Restore uses stale config:
getRestoreCommand()only read fromproject.agentConfig(current config), not from session metadata (config at spawn time). If the project config changed between spawn and restore, the session would be restored with wrong settings.Typecheck CI failure:
pnpm -r typecheckran all packages in parallel, but agent plugins depend on built type definitions from@composio/ao-core. Without building core first, TypeScript couldn't find new interface methods.Changes
packages/core/src/metadata.ts— Addpermissions,model,restoredAtto bothreadMetadata()andwriteMetadata()packages/core/src/types.ts— AddpermissionsandmodeltoSessionMetadatainterfacepackages/plugins/agent-claude-code/src/index.ts—getRestoreCommand()now prefers persisted metadata over project config, with fallback for older sessionspackage.json— Build core before running typecheck across workspaceTest plan
🤖 Generated with Claude Code