🗑️ reduce reused code, add retryable http attempts and unified logging - #19
Merged
Merged
Conversation
Every provider send() now logs: debug before request, error on HTTP failure (with URL, status, response body), error on stream read errors, and debug on stream start. Adds logging standard to CLAUDE.md. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Priority: PHX_LOG env var > project .phx/phx.json > global ~/.phx/phx.json > "info" default. Add "log_level" field to Config schema with merge support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract duplicated HTTP calling code from all four providers (Anthropic, OpenAI, Google, Ollama) into a shared src/http/ module. Each provider now uses http::send_streaming() instead of manual reqwest calls, eliminating ~100 lines of duplicated client creation, status checking, and error logging. Add retry with exponential backoff (1,2,5,10,15,20,25,30,30,30s) for transient failures (429, 500, 502, 503, 504, connection errors). Max 10 attempts. Non-retryable errors (400, 401, 403) fail immediately. Retry status is shown inline in the TUI chat as system messages. The retry wait is interruptible via Esc/Ctrl-C. Changes: - New src/http/mod.rs with send_streaming, is_retryable, backoff_delay - Provider::send() now takes &SendOptions (was by-value) - Retry loop in session/conversation.rs and session/agent_loop.rs - ConvEvent::Retrying and ConvEvent::RetryRecovered for TUI feedback - Msg::ConvRetrying and Msg::ConvRetryRecovered with update handlers - Version bump to 0.6.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract shared SSE stream parser (SseParser) into src/http/sse.rs used by all four providers. Centralize Message-to-ProviderMessage conversion into session::message::to_provider_messages, removing duplicate mapping from conversation.rs and agent_loop.rs. Add ToolSchema::to_openai_json and to_simple_json to eliminate repeated tool JSON construction. Extract render_picker_list into picker.rs, consolidating modal_picker and command_completion rendering. Fix MockProvider to use non-retryable error so tests don't hang on retry backoff. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… per spec Previously, next_double() tried to parse each data: line individually as JSON. Per the SSE spec, multiple data: lines in a block should be joined with newlines before interpretation. This caused split JSON payloads to fall through as Raw instead of Data. Adds regression test: double_newline_concatenates_multiline_data Closes PHX-507
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.
No description provided.