Skip to content

fix: avoid MissingGreenlet during OKR focus upsert - #814

Merged
yaojin3616 merged 1 commit into
mainfrom
agent/debugger/5cb9c4db
Aug 5, 2026
Merged

fix: avoid MissingGreenlet during OKR focus upsert#814
yaojin3616 merged 1 commit into
mainfrom
agent/debugger/5cb9c4db

Conversation

@yaojin3616

Copy link
Copy Markdown
Collaborator

Summary

  • Refresh focus items after flushing an outer async session and before serializing them.
  • Add regression coverage for the flush/refresh ordering.

Root cause

_upsert_focus_item_impl() serialized created_at and updated_at after flush() without loading server-generated values. With the asyncpg-backed SQLAlchemy session used by OKR startup seeding, that could cause an implicit lazy load outside the greenlet context and raise MissingGreenlet.

Validation

  • PYTHONPATH=. uv run pytest tests/test_agent_seeder_storage_repair.py tests/test_focus_service.py
  • PYTHONPATH=. uv run ruff check app/services/focus_service.py tests/test_focus_service.py

Fixes #813

@yaojin3616
yaojin3616 marked this pull request as ready for review August 5, 2026 03:10
@yaojin3616
yaojin3616 merged commit 4075721 into main Aug 5, 2026
1 check was pending
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.

[Bug] OKR Agent patch 可能触发 MissingGreenlet 错误

1 participant