Client Engagement Billing Dispatch Script Generator
Generates a Python tool calling harness to reconcile unbilled hours and trigger billing adjustments across enterprise ERP systems.
Use this template when professional services firms need an automated agent tool schema and script to detect billing anomalies, verify partner rate caps, and dispatch invoice adjustments.
Role: Senior Billing Systems Integration Architect with fifteen years of experience in professional services financial operations.
Context
- Professional services practice: {{firm_practice_area}}
- Target ERP platform: {{erp_system_name}}
- Billing contract rules: {{billing_rate_structure}}
- Discrepancy trigger level: {{discrepancy_threshold}}
- Designated approver role: {{approval_authority}}
- Target currency denomination: {{currency_code}}
Task
Draft an end-to-end Python tool calling handler script and JSON schema specifications that an agent can execute to ingest timecard logs, identify unbilled leakage, validate variance thresholds, and post adjustment drafts to {{erp_system_name}}.
Method
- Define OpenAPI-compatible JSON schemas for three distinct tools: timecard log retrieval, partner rate validation against {{billing_rate_structure}}, and billing adjustment submission.
- Construct the tool execution dispatcher capable of mapping agent function call requests into executable Python handlers.
- Implement argument validation logic to verify that all financial figures use {{currency_code}} and align with {{firm_practice_area}} standards.
- Write mathematical comparison routines evaluating recorded consultant hours against {{discrepancy_threshold}}.
- Embed an approval routing branch requiring confirmation from {{approval_authority}} when rate overrides exceed policy.
- Add comprehensive error handling for ERP network timeouts, schema mismatches, and malformed entity IDs.
- Provide dummy test payload invocations displaying function-call routing, execution output, and formatted agent return messages.
Constraints
- The generated script MUST be syntactically valid Python 3.10+ using type hints and docstrings.
- MUST NOT hardcode mock API keys or sensitive production credentials.
- Tool schemas must explicitly mark mandatory arguments with strict type definitions.
- Error handling MUST return clean structured JSON envelopes rather than raw stack traces.
Output format
1. Function Schemas
JSON schemas for fetch_timecards, validate_rates, and post_adjustment.
2. Implementation Script
Fully commented Python module containing the dispatcher, mock ERP client, and validation rules (70-120 lines).
3. Execution Walkthrough
Step-by-step trace showing an example agent tool call, parameter parsing, and return output.
Self-review
- Verify that {{discrepancy_threshold}} and {{currency_code}} are explicitly parsed in the validation routine.
- Ensure all function definitions match OpenAI tool calling conventions.
- Check that exception paths return JSON error objects.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.