feat: examples/ demos + fix record_turn#15
Conversation
- 01_basic_workflow.py: DAG 创建、手动推进、状态查询 - 02_scheduler_and_memory.py: 自动调度、三层记忆系统 - 03_error_handling.py: 超时、取消、重试、环检测 - Fix memory/__init__.py record_turn missing workflow_id param
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
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)) |
There was a problem hiding this comment.
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)
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', {}))} 层") |
There was a problem hiding this comment.
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())).
Reviewed by Cursor Bugbot for commit 85bf31b. Configure here.


3 个端到端 demo + 修复 record_turn 参数顺序
examples/01_basic_workflow.py— DAG 创建、手动推进、状态查询examples/02_scheduler_and_memory.py— 自动调度、三层记忆系统examples/03_error_handling.py— 超时、取消、重试、环检测memory/__init__.pyrecord_turn缺少workflow_id参数导致参数错位Note
Low Risk
Low risk: adds standalone example scripts and makes a small, backward-compatible fix to
MemorySystem.record_turnto 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__.pyMemorySystem.record_turnto explicitly passworkflow_idtoEpisodicMemory.record, preventing parameter misalignment and ensuring turn events are recorded with the intendedexecution_id/metadata.Reviewed by Cursor Bugbot for commit 85bf31b. Bugbot is set up for automated code reviews on this repo. Configure here.