Skip to content

Comments

fix: persist session model/permissions in metadata for restore#129

Open
AgentWrapper wants to merge 3 commits intomainfrom
feat/RESTORE
Open

fix: persist session model/permissions in metadata for restore#129
AgentWrapper wants to merge 3 commits intomainfrom
feat/RESTORE

Conversation

@AgentWrapper
Copy link
Collaborator

Summary

Fixes metadata serialization gaps in the session restore pipeline. Three issues addressed:

  • Metadata fields silently dropped: writeMetadata() and readMetadata() didn't serialize model, permissions, or restoredAt fields, even though SessionMetadata defined them and session-manager.ts wrote them. Values were silently discarded.

  • Restore uses stale config: getRestoreCommand() only read from project.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 typecheck ran 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

  1. packages/core/src/metadata.ts — Add permissions, model, restoredAt to both readMetadata() and writeMetadata()
  2. packages/core/src/types.ts — Add permissions and model to SessionMetadata interface
  3. packages/plugins/agent-claude-code/src/index.tsgetRestoreCommand() now prefers persisted metadata over project config, with fallback for older sessions
  4. package.json — Build core before running typecheck across workspace

Test plan

  • Core unit tests pass (245/245)
  • Typecheck passes with new script
  • CI: Lint, Test, Typecheck, Integration Tests

🤖 Generated with Claude Code

AgentWrapper and others added 3 commits February 20, 2026 19:32
…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>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant