Add workflow idempotency keys to prevent duplicate provisioning#253
Merged
Conversation
mvillmow
commented
Jun 20, 2026
mvillmow
left a comment
Contributor
Author
There was a problem hiding this comment.
Idempotency keys implemented correctly and completely; both CLI paths wired, reuse/force/check covered by tests. Two minor non-blocking findings (check's event-loop fallback; team membership not reconciled on reuse).
Implement deterministic idempotency keys for agents, teams, and tasks to allow re-running workflows without creating duplicate resources. - Adds telemachy/idempotency.py with make_key() and is_telemachy_key() - Agents and teams now use stable tlm-<hash>-<name> keys as their names - AgamemnonClient gains list_teams() method and idempotency_name parameter - WorkflowExecutor detects and reuses existing resources with matching keys - Reused agents tolerate "already running" status (409/400 conflict) - Partial runs can be completed by re-running (only missing resources created) - New --force flag bypasses idempotency checks for clean-slate execution - New telemachy check <workflow> command reports orphaned tlm-* resources - Comprehensive test coverage including 6 new idempotency test cases Closes #61 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
- cli.py: drop unreachable asyncio event-loop fallback in `check` command; use plain asyncio.run() matching all sibling commands - README.md: document team-membership-not-reconciled caveat in new Idempotency section so operators know to use --force when agent IDs are stale from a partial prior run - ruff-format: reformat auto-touched files (models.py, schema.py, test_cli.py) — logic unchanged Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
Identify two core defects discovered during implementation: 1. Deprecated asyncio.iscoroutinefunction usage (executor.py:80) 2. Type annotation mismatch in CLI snapshot variable (cli.py:200) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
GHSA-4xgf-cpjx-pc3j) Signed-off-by: Micah Villmow <4211002+mvillmow@users.noreply.github.com>
mvillmow
added a commit
that referenced
this pull request
Jun 29, 2026
… idempotency-key payloads) (#289) The executor's idempotency snapshot step now calls GET /v1/teams via AgamemnonClient.list_teams() (executor.py:118), but the integration test RESPX router in tests/integration/conftest.py never registered that route, so every workflow run errored with "RESPX: GET /v1/teams not mocked!" and the unit-tests CI job (pixi run pytest, full suite) failed on main, blocking all open PRs. - Add the missing GET /v1/teams mock route (list_teams), mirroring list_agents and returning {"teams": [...]} to match the real API shape. - Update test_full_workflow.py agent-payload assertions for the workflow-scoped idempotency keys added in #253: `name` now carries the tlm-<hash>-<agent> key while `label` stays the human-readable name, and the docker payload includes hostId. Assert on the stable `label`/suffix instead of the old raw `name`. - Remove stray .claude-followup-177.md agent artifact that leaked onto main (failed non-required markdownlint; not referenced anywhere). Restores the unit-tests check to green locally (148 passed, ruff + mypy clean). Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement deterministic idempotency keys for agents, teams, and tasks to allow re-running workflows without creating duplicate resources in ProjectAgamemnon.
tlm-<sha256>-<name>keys for identification--forceflag bypasses idempotency checks for clean-slate executiontelemachy check <workflow>command reports orphaned tlm-* resourcesChanges
src/telemachy/idempotency.py— deterministic key generation and recognitionlist_teams()method and optionalidempotency_nameparameter to create_agent--forceflag)--force/--no-forceflag toruncommand with orphan warningchecksubcommand to report orphaned resourcesTest Results
Verification
✅ Idempotency key generation is deterministic and collision-safe
✅ Re-running a workflow reuses existing agents/teams
✅ Partial runs complete missing resources
✅ --force flag bypasses idempotency
✅ Already-running agents are tolerated
✅ Non-conflict errors propagate correctly
✅ check command reports orphaned resources
Closes #61