Skip to content

🗑️ reduce reused code, add retryable http attempts and unified logging - #19

Merged
apriendeau merged 8 commits into
mainfrom
austin/cleanup-logging
May 25, 2026
Merged

apriendeau merged 8 commits into
mainfrom
austin/cleanup-logging

Conversation

@apriendeau

Copy link
Copy Markdown
Contributor

No description provided.

apriendeau and others added 5 commits May 24, 2026 18:09
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>
@apriendeau apriendeau self-assigned this May 25, 2026
@apriendeau apriendeau changed the title 🗑️ reduce reused code 🗑️ reduce reused code, add retryable http attempts and unified logging May 25, 2026
… 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
@apriendeau
apriendeau merged commit 5c3acba into main May 25, 2026
3 checks passed
@apriendeau
apriendeau deleted the austin/cleanup-logging branch May 25, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant