Skip to content

Feature/kaifeng.yan/fix opencode version - #85

Closed
Million-mo wants to merge 47 commits into
develop/agenticfrom
feature/kaifeng.yan/fix_opencode_version
Closed

Feature/kaifeng.yan/fix opencode version#85
Million-mo wants to merge 47 commits into
develop/agenticfrom
feature/kaifeng.yan/fix_opencode_version

Conversation

@Million-mo

Copy link
Copy Markdown
Owner

修复opencode更新导致的通信问题

备份迁移自 SRC-PR#16 · 作者 @ykf173 · 创建于 2026-04-16T16:17:06Z · head=feature/kaifeng.yan/fix_opencode_version base=develop/agentic
源状态: closed

yankaifeng and others added 30 commits April 18, 2026 19:04
…exhaustiveness warning

- Add global_router to conftest.py app fixture for SSE integration testing
- Remove unused MemoryStorageProvider import from conftest.py
- Add logger.warning for unhandled event types in _extract_session_id wildcard case
…ption isolation

- Add SSEStream class and global_event_stream fixture to conftest.py
- Add parse_sse_event helper for SSE data line parsing
- Add exception isolation to broadcast_event: iterate copy, put_nowait, catch QueueFull
- Safe queue removal in _event_generator finally block with contextlib.suppress
- Add race condition analysis comment for on_first_subscriber callback
…iff.patch, workspace routing, session_id extraction

- Migrate top-level variant into model.variant for UserMessage/MessageRequest (backward-compat)
- Replace FileDiff.before/after with FileDiff.patch matching OpenCode v1.4.0+ schema
- Add WorkspaceInfo/WorkspaceConnectionStatus models and /experimental/workspace endpoints
- Add workspace field to GlobalEvent envelope for TUI routing
- Fix base_path to anchor on server working_dir, not agent env.cwd
- Extend _extract_session_id for 6 additional event types (22 total)
- Add /global/diagnostic and /global/routing-check endpoints
- Add DiagnosticResponse model
- Update tests for new models and routing behavior
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Keep OpenCode question prompts on the que_* namespace while preserving the legacy permission bridge through /question. The regression tests cover both the new question prefix and the fallback permission reply path.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Keep /global/event fully envelope-shaped so 1.4.4+ clients keep consuming after idle timeouts. Normalizing the routing directory in ServerState keeps the envelope aligned with the TUI filter.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Refresh the compliance suite for wrapped heartbeat events and normalized routing metadata. This keeps the regression coverage aligned with the updated /global/event contract.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…wrap()

Add explicit no-session case block in _extract_session_id for all 16 event types that have no session association (ServerHeartbeatEvent, ServerConnectedEvent, FileWatcherUpdatedEvent, FileEditedEvent, etc.), eliminating spurious logger.warning spam on every broadcast. Replace redundant json.loads(_serialize_event()) in GlobalEventFactory.wrap() with direct model_dump() for better performance.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Expand _extract_session_id tests: verify all 16 no-session events return None without warnings, add test for unknown event types still triggering the case _ warning fallback, update docstrings to reflect GlobalEventFactory.wrap() using model_dump directly.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…ribute access

Add public has_pending_permission() method to OpenCodeInputProvider and use it in permission_routes.py instead of directly accessing _pending_permissions.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…t race

Refactor _serialize_event into _event_to_dict (dict) + _serialize_event (string wrapper) so GlobalEventFactory.wrap() and _event_generator avoid redundant serialization round-trips. Add docstring comments in session_routes.py noting the shared-agent singleton race condition for multi-session scenarios.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…torage

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
yankaifeng and others added 17 commits April 18, 2026 19:09
- Add RunSnapshot dataclass to capture per-run state (session_id,
  input_provider, conversation, model_name, mode_name, parent_session_id)
- Add agent_lock to ServerState for short critical section around
  session binding and snapshot capture only
- Add per-session MessageHistory instances (session_conversations) for
  conversation isolation between concurrent runs
- Narrow lock scope in message_routes: hold agent_lock only during
  bind/snapshot, then release before run_stream()
- Thread RunSnapshot through base_agent.run_stream() → _run_stream_once()
  → _stream_events(); agents use snapshot.session_id instead of live
  self.session_id for event emission
- Refactor interrupt() to accept session_id for targeted per-session
  cancellation instead of global _cancelled flag
- Add cancel_session_run() to ServerState for session-scoped task cancel
- Update abort_session to use cancel_session_run + interrupt(session_id=)
- Add QA tests: two-sessions-back-to-back, in-flight snapshot isolation
Apply snapshot pattern from Task 1 to session route flows:
- _execute_slashed_command: capture snapshot under agent_lock, pass to run_stream
- _execute_skill_command: move load_session + snapshot inside agent_lock
- init_session: capture snapshot for background agent.run()
- summarize_session: capture snapshot, use snapshot.conversation for compaction
- get_or_load_session: wrap agent binding in agent_lock (fast path stays lockless)
- Add test_read_only_route_during_active_turn QA test
@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-17T16:50:52Z(备份迁移)

/gimini review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-17T16:55:30Z(备份迁移)

@gemini-code-assist /review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-18T11:11:16Z(备份迁移)

@gemini-code-assist /review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-18T11:42:08Z(备份迁移)

@gemini-code-assist /review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-19T07:38:33Z(备份迁移)

@gemini-code-assist /review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-19T08:39:34Z(备份迁移)

@gemini-code-assist /review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-19T09:45:35Z(备份迁移)

@gemini-code-assist /review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-19T10:39:47Z(备份迁移)

@gemini-code-assist /review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-19T15:32:10Z(备份迁移)

@gemini-code-assist /review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @ykf173 于 2026-04-20T00:23:06Z(备份迁移)

@gemini-code-assist /review

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