refactor: make threads python skill synchronous
68 unmodified lines69707172737475767374757677787980122 unmodified linesExpand all68 unmodified lines
agents can inspect and control threads programmatically from the python REPL using the bundled `threads` skill:
```pythonawait threads.list() # list open and closed threadsawait threads.complete("t1", reason="done in test") # mark thread completeawait threads.dismiss("t2", reason="obsolete") # dismiss unwanted threadawait threads.reopen("t3") # reopen a closed threadthreads.list() # list open and closed threadsthreads.complete("t1", reason="done in test") # mark thread completethreads.dismiss("t2", reason="obsolete") # dismiss unwanted threadthreads.reopen("t3") # reopen a closed thread```
nothing is hidden: every thread the model tracks is visible and correctable here.
122 unmodified linesExpand all7 unmodified lines89101112131415121314151617181920212223202122237 unmodified linesThe commitment observer tracks open user requests across turns so multi-part requests are never forgotten.Use this skill to inspect and update tracked threads directly from Python:
```pythonawait threads.list()await threads.complete("t1")await threads.dismiss("t2")await threads.reopen("t3")threads.list()threads.complete("t1")threads.dismiss("t2")threads.reopen("t3")```
## API
- `await threads.list()` — list all open and closed threads as structured dicts (`id`, `status`, `canonicalRequest`, `missing`, etc.).- `await threads.complete(thread_id, reason=None)` — mark a thread as completed (`status: done`).- `await threads.dismiss(thread_id, reason=None)` — dismiss an obsolete or unwanted thread (`status: dismissed`).- `await threads.reopen(thread_id)` — reopen a closed thread (`status: open`).- `threads.list()` — list all open and closed threads as structured dicts (`id`, `status`, `canonicalRequest`, `missing`, etc.).- `threads.complete(thread_id, reason=None)` — mark a thread as completed (`status: done`).- `threads.dismiss(thread_id, reason=None)` — dismiss an obsolete or unwanted thread (`status: dismissed`).- `threads.reopen(thread_id)` — reopen a closed thread (`status: open`).100 unmodified lines1011021031041051051061071081091101111121131131141151161175 unmodified lines1231241251261271271281291301315 unmodified lines1371381391401411411421431441456 unmodified lines100 unmodified lines
return threads
async def list(status: str | None = None) -> list[dict[str, Any]]:def list(status: str | None = None) -> list[dict[str, Any]]: """List tracked commitment threads. Optional filter by status ('open', 'active', 'done', etc.).""" all_threads = _read_threads() if status is not None: return [t for t in all_threads if t["status"] == status] return all_threads
async def complete(thread_id: str, reason: str | None = None) -> dict[str, Any]:def complete(thread_id: str, reason: str | None = None) -> dict[str, Any]: """Mark a thread complete (status: done).""" if not isinstance(thread_id, str): raise TypeError(f"thread_id must be str, got {type(thread_id).__name__}") _append_event({5 unmodified lines }) return {"status": "ok", "threadId": thread_id, "action": "accept"}
async def dismiss(thread_id: str, reason: str | None = None) -> dict[str, Any]:def dismiss(thread_id: str, reason: str | None = None) -> dict[str, Any]: """Dismiss an obsolete or unwanted thread (status: dismissed).""" if not isinstance(thread_id, str): raise TypeError(f"thread_id must be str, got {type(thread_id).__name__}") _append_event({5 unmodified lines }) return {"status": "ok", "threadId": thread_id, "action": "dismiss"}
async def reopen(thread_id: str) -> dict[str, Any]:def reopen(thread_id: str) -> dict[str, Any]: """Reopen a closed thread (status: open).""" if not isinstance(thread_id, str): raise TypeError(f"thread_id must be str, got {type(thread_id).__name__}") _append_event({6 unmodified lines