Skip to content

Fix booking payment schemas for Responses API - #19

Merged
Liang-Chun Tsai (ltsai-dev) merged 1 commit into
mainfrom
ltsai-microsoft-fix-booking-decimal-schemas
Aug 19, 2026
Merged

Fix booking payment schemas for Responses API#19
Liang-Chun Tsai (ltsai-dev) merged 1 commit into
mainfrom
ltsai-microsoft-fix-booking-decimal-schemas

Conversation

@ltsai-dev

Copy link
Copy Markdown
Contributor

Summary

Azure OpenAI Responses rejects the regex lookaround emitted by Pydantic for Decimal tool inputs, preventing external booking evaluations from starting. This change exposes payment amounts as finite JSON numbers while preserving Decimal conversion and monetary rounding inside each tool.

Changes

  • Change charge, refund, and dispute amount request fields to finite float values with Responses-compatible JSON schemas.
  • Convert validated inputs through Decimal(str(value)) before two-decimal ROUND_HALF_UP quantization.
  • Add production-schema, non-finite input, rounding, and scale regression coverage.

Test plan

  • PYTHONPATH=servers\\tb_business_ops_servers_202606 python -m pytest --quiet servers\\tb_business_ops_servers_202606\\tests\\external_booking\\payment_api\\test_process_charge.py servers\\tb_business_ops_servers_202606\\tests\\external_booking\\payment_api\\test_process_charge_dispute.py servers\\tb_business_ops_servers_202606\\tests\\external_booking\\payment_api\\test_process_refund.py
  • 71 tests passed.

Related issues

N/A

Expose payment amounts as finite JSON numbers for Responses API compatibility while preserving Decimal-based monetary rounding internally.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e32fcb7b-348e-4ff3-8c78-6b5416eb0f73

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the external booking payment tools’ request schemas to avoid Pydantic Decimal JSON-schema regex features (lookarounds) that Azure OpenAI Responses rejects, while keeping internal monetary handling in Decimal with consistent ROUND_HALF_UP quantization.

Changes:

  • Switch charge_amount, refund_amount, and dispute_amount tool inputs from Decimal to finite float (allow_inf_nan=False) to emit Responses-compatible JSON schemas.
  • Convert validated float inputs via Decimal(str(value)) and quantize to 2 decimal places using ROUND_HALF_UP before persisting.
  • Add tests covering schema shape (type: number, no pattern), rejection of non-finite inputs, and rounding behavior regression.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
servers/tb_business_ops_servers_202606/tb_business_ops_servers_202606/toolslib/external_booking/payment_api/tools/process_refund.py Makes refund amount a finite JSON number while preserving internal Decimal rounding.
servers/tb_business_ops_servers_202606/tb_business_ops_servers_202606/toolslib/external_booking/payment_api/tools/process_charge.py Makes charge amount a finite JSON number and converts to Decimal for validation/rounding.
servers/tb_business_ops_servers_202606/tb_business_ops_servers_202606/toolslib/external_booking/payment_api/tools/process_charge_dispute.py Makes dispute amount a finite JSON number and quantizes via Decimal.
servers/tb_business_ops_servers_202606/tests/external_booking/payment_api/test_process_refund.py Adds schema + non-finite validation coverage and pins float->Decimal rounding behavior.
servers/tb_business_ops_servers_202606/tests/external_booking/payment_api/test_process_charge.py Adds schema + non-finite validation coverage and pins float->Decimal rounding behavior.
servers/tb_business_ops_servers_202606/tests/external_booking/payment_api/test_process_charge_dispute.py Adds schema + non-finite validation coverage and pins float->Decimal rounding behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ltsai-dev
Liang-Chun Tsai (ltsai-dev) merged commit 7d4283c into main Aug 19, 2026
7 checks 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.

2 participants