OpenHands / OpenHands/software-agent-sdk

[Bug]: confirmation_policy, security_analyzer, and secrets mutations not persisted to meta.json

Open
#4,810 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority:medium ready-for-dev session
Dominant language
Python
Stars
1.1k
Forks
539
Avg merge
1d 19h
Merged PRs (30d)
137

Description

Bug Description

When set_confirmation_policy, set_security_analyzer, or update_secrets are called via the API, the change is written to ConversationState/base_state.json but StoredConversation/meta.json is never updated. On next startup, event_service.py lines 1090–1102 read all three fields from stored to initialize the conversation, so the changes are silently reverted after eviction or server restart.

Expected Behavior

API mutations to confirmation_policy, security_analyzer, and secrets persist across conversation eviction and server restart.

Actual Behavior

Changes are lost; the conversation reverts to the values set at creation time. This can be verified by running the existing test suite and adding a test that:

  1. Creates a conversation
  2. Calls the mutation endpoint (e.g. set_confirmation_policy)
  3. Simulates eviction by removing the event service from _event_services
  4. Reloads the conversation via _get_or_load_event_service
  5. Asserts the updated value is still present
pytest tests/agent_server/ -k "confirmation_policy or security_analyzer or secrets"

The relevant code paths are:

  • EventService.set_confirmation_policy (line 1668) — only calls self._conversation.set_confirmation_policy(policy); no self.stored update, no save_meta()
  • EventService.set_security_analyzer (line 1677) — same pattern
  • EventService.update_secrets (line 1658) — only calls self._conversation.update_secrets(secrets); no self.stored update, no save_meta()

On startup, event_service.py reads all three from stored:

# line 1090
secrets=self.stored.secrets,
# line 1101
conversation.set_confirmation_policy(self.stored.confirmation_policy)
# line 1102
conversation.set_security_analyzer(self.stored.security_analyzer)

Compare to EventService.apply_resume_secrets (lines 352–355) which correctly updates self.stored and calls await self.save_meta() after mutating state.

Acceptance Criteria
  • set_confirmation_policy updates self.stored.confirmation_policy and calls save_meta() after mutating ConversationState
  • set_security_analyzer updates self.stored.security_analyzer and calls save_meta() after mutating ConversationState
  • update_secrets updates self.stored.secrets and calls save_meta() after mutating ConversationState
  • Tests verify each change survives a simulated eviction/reload
Additional Context

Discovered while reviewing #4617. tags is currently the only field where API mutations correctly write back to stored and persist to meta.json. Discussed in #proj-agent-server.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with EventService.update_secrets, set_confirmation_policy, and set_security_analyzer in event_service.py, then compare them with apply_resume_secrets around lines 352–355. Run pytest tests/agent_server/ -k "confirmation_policy or security_analyzer or secrets" and add coverage for eviction and reload. Done means all three mutations remain present after _get_or_load_event_service reloads the conversation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.