Skip to content

feat: robust pattern-matching cost estimation and trace decorator resilience - #87

Open
archittmittal wants to merge 1 commit into
mainfrom
feat/llm-pricing-patterns
Open

feat: robust pattern-matching cost estimation and trace decorator resilience#87
archittmittal wants to merge 1 commit into
mainfrom
feat/llm-pricing-patterns

Conversation

@archittmittal

Copy link
Copy Markdown
Collaborator

This Pull Request resolves Issue #25, Issue #29, and Issue #11.

Key Changes:

  1. Pattern-Matching Price Resolution (Issue Flawed LLM Cost Estimation for Versioned and Pinned Models #25):
    • Modified packages/sdk/agentscope/_pricing.py to resolve model cost estimations using prefix/pattern matching. Base pricing patterns are sorted by length in descending order to guarantee that more specific version-pinned names (e.g. gpt-4o-2024-05-13) match before generic ones.
    • Introduced programmatic configuration overrides (update_pricing_table) and environment variable configuration overrides via AGENTSCOPE_CUSTOM_PRICING parsed dynamically at runtime.
  2. Claude 3 & Gemini 1.5 Pricing (Issue feat(sdk): Add support for Claude 3 (Haiku/Opus) and Gemini 1.5 Flash in pricing table #29):
    • Populated default price parameters in PRICING_TABLE for claude-3-haiku, claude-3-opus, and gemini-1.5-flash.
  3. Trace Decorator Resilience (Issue feat(sdk): Implement @trace custom decorator instrumentation (Sub-task 2.4) #11):
    • Covered all client setup and websocket event emission logic in safety try/except blocks in packages/sdk/agentscope/decorators.py to ensure telemetry server connectivity errors never propagate and disrupt user-defined synchronous/asynchronous logic.
  4. Verification:
    • Expanded packages/sdk/tests/test_sdk.py with test_decorators_resilience confirming telemetry emit failures do not halt execution, and added version-matching, overrides, and Claude/Gemini cost assertions to test_calculate_cost.

All tests pass successfully.

…nd trace decorator resilience (Fixes #25, Fixes #29, Fixes #11)
@github-actions github-actions Bot added pkg: sdk area: sdk/decorators type: feature Auto-generated label for type: feature labels Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: sdk/decorators pkg: sdk type: feature Auto-generated label for type: feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant