Skip to content

fix: normalize nested string-key tool arguments safely#459

Merged
mikehostetler merged 3 commits into
mainfrom
codex/fix-nested-tool-map-normalization
Feb 27, 2026
Merged

fix: normalize nested string-key tool arguments safely#459
mikehostetler merged 3 commits into
mainfrom
codex/fix-nested-tool-map-normalization

Conversation

@mikehostetler
Copy link
Copy Markdown
Contributor

@mikehostetler mikehostetler commented Feb 24, 2026

Summary

  • normalize tool input keys recursively based on parameter schema types, including nested :map, {:map, ...}, {:list, :map}, and {:list, {:map, ...}}
  • extend normalization for additional map-containing schema shapes: {:or, ...} and {:tuple, ...}
  • keep atom safety by converting only schema-known or existing atoms (String.to_existing_atom/1), never creating new atoms
  • remove remaining unsafe runtime String.to_atom/1 conversions in core runtime paths:
    • provider id inference in ReqLLM.Providers
    • model provider extraction in ReqLLM.Provider.Defaults
    • HTTP method parsing in streaming fixture context
    • Bedrock Converse role parsing
  • preserve previous top-level behavior while fixing nested tool-call payloads from providers

Tests

  • mix test --cover test/req_llm/tool_test.exs test/req_llm/schema_test.exs
  • mix test test/req_llm/providers_test.exs test/req_llm/streaming/finch_client_test.exs test/req_llm/providers/amazon_bedrock/converse_test.exs test/req_llm/provider/defaults_test.exs
  • mix test test/req_llm/tool_test.exs test/req_llm/schema_test.exs test/req_llm/providers_test.exs test/req_llm/streaming/finch_client_test.exs test/req_llm/providers/amazon_bedrock/converse_test.exs test/req_llm/provider/defaults_test.exs
  • added regression tests for:
    • nested list/map normalization
    • unknown nested key atom safety
    • {:or, ...} map normalization
    • {:tuple, ...} map normalization
    • unknown provider-prefix decode path in defaults
    • method normalization in streaming fixture HTTP context
    • unknown Bedrock role fallback handling

@mikehostetler mikehostetler merged commit b631505 into main Feb 27, 2026
6 checks passed
@mikehostetler mikehostetler deleted the codex/fix-nested-tool-map-normalization branch February 27, 2026 16:09
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