Skip to content

fix: Non-transactional multi-step context updates between metadata/to… - #1161

Merged
zmanian merged 2 commits into
stagingfrom
fix/context-updates
Mar 14, 2026
Merged

zmanian merged 2 commits into
stagingfrom
fix/context-updates

Conversation

@nickpismenkov

Copy link
Copy Markdown
Contributor

…ken setup and DB

Summary

Change Type

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • CI/Infrastructure
  • Security
  • Dependencies

Linked Issue

Validation

  • cargo fmt
  • cargo clippy --all --benches --tests --examples --all-features
  • Relevant tests pass:
  • Manual testing:

Security Impact

Database Impact

Blast Radius

Rollback Plan


Review track:

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added size: M 50-199 changed lines scope: agent Agent core (agent loop, router, scheduler) risk: medium Business logic, config, or moderate-risk modules contributor: experienced 6-19 merged PRs and removed size: M 50-199 changed lines labels Mar 14, 2026
@github-actions github-actions Bot added the size: M 50-199 changed lines label Mar 14, 2026

@zmanian zmanian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review: Atomic context update-and-get to prevent concurrent interleaving

Clean fix for Issue #807. update_context() + get_context() were two separate lock acquisitions, allowing concurrent workers to modify state between them. New update_context_and_get() holds the write lock for both operations.

Positives:

  • update_context_and_get returns the cloned context under the same write lock
  • Scheduler uses the returned context directly for save_job, no second read needed
  • Edge case handled: metadata=None AND max_tokens=0 falls through to plain get_context()
  • Regression test and concurrency test both verify atomicity

LGTM.

@zmanian
zmanian enabled auto-merge (squash) March 14, 2026 19:01
@zmanian
zmanian merged commit 3f2796b into staging Mar 14, 2026
14 checks passed
@zmanian
zmanian deleted the fix/context-updates branch March 14, 2026 20:06
@ironclaw-ci ironclaw-ci Bot mentioned this pull request Mar 17, 2026
Copilot AI mentioned this pull request Mar 19, 2026
11 tasks
bkutasi pushed a commit to bkutasi/ironclaw that referenced this pull request Mar 28, 2026
nearai#1161)

* fix: Non-transactional multi-step context updates between metadata/token setup and DB

* fix: code style
drchirag1991 pushed a commit to drchirag1991/ironclaw that referenced this pull request Apr 8, 2026
nearai#1161)

* fix: Non-transactional multi-step context updates between metadata/token setup and DB

* fix: code style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: experienced 6-19 merged PRs risk: medium Business logic, config, or moderate-risk modules scope: agent Agent core (agent loop, router, scheduler) size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CRITICAL] Non-transactional multi-step context updates between metadata/token setup and DB

2 participants