Skip to content

feat: AST-targeted id/name swap for delay control utterances - #186

Open
Ruari-Phipps wants to merge 1 commit into
mainfrom
feat/delay-control-reference-swap
Open

feat: AST-targeted id/name swap for delay control utterances#186
Ruari-Phipps wants to merge 1 commit into
mainfrom
feat/delay-control-reference-swap

Conversation

@Ruari-Phipps

Copy link
Copy Markdown
Collaborator

Summary

Scopes the {{prefix:value}} reference swap in Function.make_pretty/from_pretty to only delay control utterance messages, using AST to precisely locate the string literals within @func_latency_control decorators.

Motivation

  • make_pretty had a bug: replace_resource_ids_with_names return value was silently discarded
  • from_pretty applied replace_resource_names_with_ids to the entire function code instead of only delay control messages
  • validate() had a bug where resource_mappings parameter was overwritten by kwargs.get("resource_mappings") (always None after the signature change)

Changes

  • Add _swap_latency_control_references static method that uses AST to find @func_latency_control decorator message strings and applies swap via positional replacement
  • Fix make_pretty to use targeted swap (previously no-op due to unused return value)
  • Scope from_pretty swap to delay control utterances only
  • Fix validate() parameter shadowing bug
  • Add DELAY_CONTROL_REFERENCES constant and delay response reference validation in validate()
  • Add 12 tests for _swap_latency_control_references covering both directions, body isolation, edge cases, and roundtrip

Test strategy

  • Added/updated unit tests
  • Manual CLI testing (poly <command>)
  • Tested against a live Agent Studio project
  • N/A (docs, config, or trivial change)

Checklist

  • ruff check . and ruff format --check . pass
  • pytest passes
  • No breaking changes to the poly CLI interface (or migration path documented)
  • Commit messages follow conventional commits

🤖 Generated with Claude Code

The make_pretty/from_pretty methods on Function now swap {{prefix:value}}
references only within @func_latency_control delay response messages,
using AST to precisely locate the string literals. This fixes a bug
where make_pretty silently discarded the swap (unused return value) and
scopes the from_pretty swap to delay control utterances instead of the
entire function code.

Also fixes validate() overwriting its resource_mappings parameter with
kwargs.get("resource_mappings") which was always None after the
signature change, and adds delay response reference validation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Ruari-Phipps
Ruari-Phipps requested a review from a team June 12, 2026 16:26
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Base (main) PR Change
70.0% 70.1% +0.1% ✅

Changed file coverage

File Coverage Change
poly/resources/function.py 81.3% +0.1% ✅

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had any activity in 30 days. It will be closed in 7 days if no further activity occurs. If this is still in progress, please push an update or leave a comment.

@github-actions github-actions Bot added the stale label Jul 13, 2026
@Ruari-Phipps

Copy link
Copy Markdown
Collaborator Author

WIP

@github-actions github-actions Bot removed the stale label Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had any activity in 30 days. It will be closed in 7 days if no further activity occurs. If this is still in progress, please push an update or leave a comment.

@github-actions github-actions Bot added the stale label Aug 14, 2026
@Ruari-Phipps

Copy link
Copy Markdown
Collaborator Author

bump

@github-actions github-actions Bot removed the stale label Aug 15, 2026
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