lemonade-client-patterns

Guides safe modifications to LemonadeClient, its callers, and the GAIA test suite.

1.6k|168|Updated Dec 16, 2024
One-click install
npx skills add https://github.com/amd/gaia --skill lemonade-client-patterns-amd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lemonade-client-patterns
Source: https://github.com/amd/gaia/tree/main/.claude/skills/lemonade-client-patterns
Command: npx skills add https://github.com/amd/gaia --skill lemonade-client-patterns-amd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Changes to GAIA's LemonadeClient ripple through providers, VLMClient, UI routers, and the base Agent class, and subtle mistakes (missed HTTP call sites, wrong patch targets, leaked API keys in error messages) cause regressions and security issues. This Skill encodes the patterns and gotchas needed to thread changes through the codebase correctly. ## Core Features & Use Cases - HTTP call-site enumeration: Ensures changes like auth headers reach every outbound call, including direct requests.post sites that bypass _send_request. - Security conventions: Enforces fixed-string 401 errors and correct OpenAI SDK exception ordering so API keys never leak into logs or CLI output. - Testing guidance: Covers responses vs httpx mocking, deferred-import patch targets, SSE test termination, and verifying failures against main. - Use Case: When adding a new LemonadeClient.__init__ parameter, follow the Skill to update the factory, the provider's backend_kwargs forwarding, and all affected tests. ## Quick Start Apply the lemonade-client-patterns skill to add an auth header to every Lemonade HTTP call site in lemonade_client.py.

Frequently Asked Questions about lemonade-client-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new parameter to LemonadeClient in GAIA?

Add the parameter to LemonadeClient.__init__, then update the create_lemonade_client() factory to accept and forward it. Also update LemonadeProvider to pass it via the backend_kwargs dict using conditional forwarding.

How do I mock LemonadeClient in Python tests with deferred imports?

Patch at the source module where the class is defined: mocker.patch("gaia.llm.lemonade_client.LemonadeClient"). Patching the importing module fails with AttributeError because deferred imports never bind the name at module level.

Why do SSE tests hang when using the responses library?

Tests block forever on iter_lines() unless the mocked body is a complete SSE event ending with a double newline. Provide a body like "event: complete\ndata: {}\n\n" with stream=True and consume only one item from the generator.

Why should 401 error messages never include response.text?

Misconfigured reverse proxies can reflect the Authorization header back in a 401 response body, leaking the API key into CLI output and logs. Use a fixed-string error message that names LEMONADE_API_KEY without including the response body.

Does openai.AuthenticationError get caught by openai.APIError handlers?

No, AuthenticationError is not a subclass of APIError in openai>=1.0. It must be caught in a separate except clause placed before the generic APIError handler, since Python evaluates except clauses in order.