Skip to content

feat: examples/ demos + fix record_turn#15

Merged
SonicBotMan merged 1 commit intomainfrom
chore/examples-and-cleanup
Apr 22, 2026
Merged

feat: examples/ demos + fix record_turn#15
SonicBotMan merged 1 commit intomainfrom
chore/examples-and-cleanup

Conversation

@SonicBotMan
Copy link
Copy Markdown
Owner

@SonicBotMan SonicBotMan commented Apr 22, 2026

3 个端到端 demo + 修复 record_turn 参数顺序

  • examples/01_basic_workflow.py — DAG 创建、手动推进、状态查询
  • examples/02_scheduler_and_memory.py — 自动调度、三层记忆系统
  • examples/03_error_handling.py — 超时、取消、重试、环检测
  • Fix: memory/__init__.py record_turn 缺少 workflow_id 参数导致参数错位

Note

Low Risk
Low risk: adds standalone example scripts and makes a small, backward-compatible fix to MemorySystem.record_turn to avoid mis-ordered args when calling episodic recording.

Overview
Adds three runnable demo scripts under examples/ covering (1) DAG creation + manual step advancement + status/progress checks, (2) scheduler-driven parallel execution with a mock executor plus working/episodic/semantic memory usage, and (3) timeout, retry, cancellation, and cycle-detection scenarios.

Fixes hermes-plugin/memory/__init__.py MemorySystem.record_turn to explicitly pass workflow_id to EpisodicMemory.record, preventing parameter misalignment and ensuring turn events are recorded with the intended execution_id/metadata.

Reviewed by Cursor Bugbot for commit 85bf31b. Bugbot is set up for automated code reviews on this repo. Configure here.

- 01_basic_workflow.py: DAG 创建、手动推进、状态查询
- 02_scheduler_and_memory.py: 自动调度、三层记忆系统
- 03_error_handling.py: 超时、取消、重试、环检测
- Fix memory/__init__.py record_turn missing workflow_id param
@SonicBotMan SonicBotMan merged commit 2c3a7c8 into main Apr 22, 2026
2 checks passed
Copy link
Copy Markdown

@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 2 potential issues.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because on-demand usage is turned off. To enable Bugbot Autofix, turn on on-demand usage and set a spend limit in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 85bf31b. Configure here.

store.initialize()

ws = WorkflowService(store)
ws.set_scheduler(Scheduler(store, ws))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Setting scheduler causes background execution race with manual advances

Medium Severity

Calling ws.set_scheduler(...) causes start_workflow to automatically fire asyncio.create_task(self._scheduler.execute_workflow(workflow_id)) in the background using the default executor. The rest of the example then performs manual advance_step calls on the same steps, creating a race between the background scheduler and the manual advances. Example 02 correctly avoids this by not calling set_scheduler.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 85bf31b. Configure here.

print(f" 工作流 ID: {wf['id'][:8]}...")
print(f" 状态: {wf['state']}")
print(f" 步骤数: {len(wf['steps'])}")
print(f" DAG 层级: {len(wf.get('layers', {}))} 层")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layer count displays step count instead of layers

Low Severity

wf.get('layers', {}) is a dict mapping each step_id to its layer index. len() of this dict returns the number of steps (6), not the number of unique layers (5: layers 0 through 4). The display "DAG 层级: 6 层" is incorrect — it needs to count unique values, e.g. len(set(wf.get('layers', {}).values())).

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 85bf31b. Configure here.

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.

2 participants