Fix agentic-traffic reliability and enable provider prompt caching - #91
Open
veerareddyvishal144 wants to merge 1 commit into
Open
Fix agentic-traffic reliability and enable provider prompt caching#91veerareddyvishal144 wants to merge 1 commit into
veerareddyvishal144 wants to merge 1 commit into
Conversation
Measured on ITSMBench + terminal-bench via a pi-agent harness; each fix
addresses a defect observed in production-like agent loops:
- openai-router: never serve a clean empty completion. Upstream 429-retry
exhaustion surfaced as a contentless 200 with finish_reason=stop, which
agent clients read as "task complete" and terminated mid-task (observed
killing 6/7 benchmark episodes). Abort the SSE stream instead so clients
retry.
- databricks (Azure Responses): forward reasoning effort (was silently
dropped — thinking requests never reached the model), fix
max_output_tokens (read from max_completion_tokens for gpt-5.x), and
surface cache_read_input_tokens through both response conversions so
telemetry records provider cache hits (was always null).
- Prefix stability for provider prompt caching (measured 0-3% -> 92-95%
cache hit rate, ~5x real cost cut on agent loops):
* deterministic tool-call fallback IDs (were Date.now()+random — history
re-randomized every turn)
* one constant system prompt per conversation (continuations previously
swapped in a generic prompt, which also silently discarded the client
agent's instructions after turn 1)
* uniform system-reminder stripping on every turn
* content-hash tee IDs in the tool-result compressor (were timestamped —
new bytes in old messages each turn)
* fixed compression threshold (routed tier flaps between turns; COMPLEX
keeps compression deterministic and lightly lossy)
* prompt_cache_key on Azure gpt-5.x requests (session id or first-user-
message hash)
- config: TOOL_RESULT_COMPRESSION_ENABLED env knob (was hardcoded)
- nodemon.json: ignore self-written data/db files (restart-storm fix)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Agent loops through Lynkr were silently degraded in four ways, all observed and measured on ITSMBench / terminal-bench harnesses (pi agent, Azure gpt-5.6-sol):
finish_reason: stop; agent clients read that as "done" and stopped. Killed 6/7 benchmark episodes in one run.reasoning_effortwas dropped on the Azure Responses path; thinking requests silently ran at minimum effort.max_output_tokenswas also unset for gpt-5.x (read from the wrong key).Date.now()+random), the system-prompt swap, conditional reminder-stripping, timestamped tee IDs in tool-result compression, tier-flapping compression thresholds — so prefixes never matched and every token billed at full price.Fix
openai-router: guard that aborts the SSE stream (client retries) instead of serving a clean empty completion.databricks: forwardreasoning.effort; fixmax_output_tokens; surfacecache_read_input_tokensthrough both response conversions into telemetry; addprompt_cache_key(session id or first-user-message hash) on gpt-5.x requests.config: newTOOL_RESULT_COMPRESSION_ENABLEDenv knob (was hardcoded).nodemon.json: ignore self-written data/db files (dev restart storms).Measured results
Behavior changes for review
Known issue (follow-up, not addressed here)
Terminal-bench A/B shows Lynkr still costs significant quality on long compute-heavy coding tasks (direct 17/22 vs through-Lynkr 8/21), dominated by agent timeouts from per-turn latency (buffered non-streaming upstream calls). Fix is true streaming passthrough — proposed as a follow-up issue.
🤖 Generated with Claude Code