Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.

fix(agentspec): replace assert with proper AgentSpecError exception - #2055

Closed
hobostay wants to merge 1 commit into
MoonshotAI:mainfrom
hobostay:fix/agentspec-assert-to-exception
Closed

hobostay wants to merge 1 commit into
MoonshotAI:mainfrom
hobostay:fix/agentspec-assert-to-exception

Conversation

@hobostay

@hobostay hobostay commented Apr 24, 2026 •

Copy link
Copy Markdown

Summary

  • Replace assert agent_spec.extend is None with a proper AgentSpecError exception in agentspec.py

Why

Using assert for production control flow is unsafe because Python's -O (optimize) flag strips all assertions, silently disabling this safety check. The assertion guards that recursive agent spec inheritance is fully resolved — if skipped, an unresolved extend could propagate and cause confusing downstream errors.

The fix replaces the assert with a raise AgentSpecError(...), which is always enforced regardless of optimization flags.

Test plan

  • Existing tests in tests/ related to agent spec loading should continue to pass
  • Verify that running python -O no longer silently skips this check

🤖 Generated with Claude Code


Open in Devin Review

Using `assert` for production control flow is unsafe because assertions
are stripped when Python runs with the `-O` flag. This replaces the
assert that checks `extend` is resolved with a proper `AgentSpecError`
exception that is always enforced.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant