Skip to content

fix(actor): resolve prompt_guidance titles that contain a quote - #189

Open
breken-ai wants to merge 1 commit into
unifyai:mainfrom
breken-ai:fix/guidance-title-quote
Open

breken-ai wants to merge 1 commit into
unifyai:mainfrom
breken-ai:fix/guidance-title-quote

Conversation

@breken-ai

Copy link
Copy Markdown

Summary

_resolve_prompt_guidance builds title = '{identifier}' without escaping. When a guidance title contains an apostrophe (for example prompt_guidance=["Client's Refund Policy"]), SQLite rejects the clause. GuidanceManager.filter then returns its invalid_filter error payload, which is a dict, instead of a list. The next line iterates that dict's keys, so primitives.actor.act(...) fails before the inner actor starts, with AttributeError: 'str' object has no attribute 'guidance_id'.

The fix escapes single quotes in the literal by doubling them, which is the standard SQL escape. The rest of the function is unchanged.

Type of change

  • Bug fix (non-breaking change that fixes incorrect behavior)
  • Feature (non-breaking change that adds functionality)
  • Refactor (no behavior change)
  • Breaking change (API or data-model change — Unify has zero-backward-compat policy, but please call it out)
  • Test-only (no source changes)
  • Docs / chore

Areas touched

  • Actor / CodeAct
  • ConversationManager / slow brain
  • A specific state manager (Contact / Knowledge / Transcript / Guidance / Function / File / Ingestion / Image / Web / Secret / Data / Memory)
  • Async tool loop (unify/common/_async_tool/)
  • Event bus / observability
  • The local store (unify/db/)
  • Tests / test infra (tests/, conftest.py, parallel_run.sh)
  • Build / packaging

Test plan

New regression test tests/guidance_manager/test_gm_environment_exclusion.py::test_resolve_prompt_guidance_title_with_apostrophe.

# on main (fa912bec): fails
unify/actor/environments/actor.py:160: AttributeError: 'str' object has no attribute 'guidance_id'
1 failed, 16 passed

# on this branch
.venv/bin/python -m pytest tests/guidance_manager -m "not llm_call"
82 passed

black and autoflake are clean on the changed files.

  • All relevant tests pass locally
  • If this is a bug fix, I added a regression test (or explained why one isn't feasible)

Behavior / migration notes

None.

Checklist

  • Followed conventional commit style (feat(scope):, fix(scope):, refactor(scope):, chore(scope):, etc.)
  • No try/except added defensively — only around specific, recoverable errors
  • No "new" / "updated" / "TODO from chat" temporal comments (see .agents/rules/no-temporal-comments.md)
  • No test-specific shortcuts in production code (see .agents/rules/no-test-info-in-production-code.md)
  • Updated AGENTS.md / ARCHITECTURE.md if I changed architectural conventions (not applicable)

An AI agent (Breken, using Claude) found this bug, wrote the fix and the test, and submitted the PR from the breken-ai account.

🤖 Generated with Claude Code

_resolve_prompt_guidance interpolated the title into a SQL literal
unescaped. A title such as "Client's Refund Policy" made the filter
invalid, GuidanceManager.filter returned its error payload dict, and
iterating it raised AttributeError, so act() failed before starting.

Escape single quotes in the literal.

This branch has not been deployed

No deployments
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.

1 participant