Skip to content

feat: add universal action parser#4

Merged
abrichr merged 1 commit intomainfrom
feat/universal-action-parser
Mar 29, 2026
Merged

feat: add universal action parser#4
abrichr merged 1 commit intomainfrom
feat/universal-action-parser

Conversation

@abrichr
Copy link
Copy Markdown
Member

@abrichr abrichr commented Mar 29, 2026

Summary

  • Adds openadapt_types.parsing module with five public functions that convert DSL strings, JSON strings, and BenchmarkAction-style dicts into the canonical Action model
  • Supports three JSON conventions (canonical nested target, legacy flat x/y, legacy openadapt-ml coordinate list), DSL with Thought:/Action: prefixes, markdown fences, and coordinate normalization detection
  • All malformed input gracefully returns Action(type=ActionType.DONE) with a logged warning -- never raises

Test plan

  • 66 new tests in tests/test_parsing.py covering DSL, JSON, auto-detect, and BenchmarkAction round-trip
  • All 109 tests pass (66 new + 43 existing) with zero regressions
  • Verify downstream consumers (openadapt-evals, openadapt-ml) can replace their local parsers with these functions

🤖 Generated with Claude Code

…formats

Adds openadapt_types.parsing module with five public functions:
- parse_action(): auto-detect format (DSL or JSON) and parse
- parse_action_dsl(): parse DSL strings like CLICK(x=0.5, y=0.3)
- parse_action_json(): parse JSON with canonical, flat, and coordinate formats
- from_benchmark_action(): convert BenchmarkAction-style dicts to Action
- to_benchmark_action_dict(): convert Action back to BenchmarkAction dict

Handles Thought:/Action: prefixes, markdown fences, coordinate normalization
detection, clamping, and legacy field mapping. All edge cases return
Action(type=DONE) with a logged warning instead of raising.

Includes 66 tests covering DSL, JSON, auto-detect, and BenchmarkAction
round-trip conversion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@abrichr abrichr merged commit 0c2ac58 into main Mar 29, 2026
1 check passed
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