Repository navigation
fix(providers): Anthropic reload and parallel results, local probe retry #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adriannoes
wants to merge
6
commits into
development
Choose a base branch
from
fix/providers-anthropic-local
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
139c9cb
fix(providers): apply live config reload to Anthropic
adriannoes ef965e0
fix(providers): send parallel Anthropic tool results in one user message
adriannoes be7e281
fix(providers): retry the local probe after a startup miss
adriannoes ccbfa38
fix(providers): throttle the local re-probe while unavailable
adriannoes 77d2bfc
test(anthropic): cover tool-result grouping boundaries
adriannoes fa52090
docs(providers): document local re-probe throttle and consolidated fixes
adriannoes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| /** | ||
| * @file local.c | ||
| * @brief OpenAI-compatible Chat Completions client for llama-server; init probe marks unreachable without failing startup. | ||
| * A later chat probes again so a server that was down only at startup can still serve. | ||
| */ | ||
|
|
||
| #define _POSIX_C_SOURCE 200809L | ||
|
|
@@ -14,14 +15,17 @@ | |
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include <time.h> | ||
|
|
||
| #define REQUEST_TIMEOUT_SEC 120 | ||
| #define CONNECT_TIMEOUT_SEC 30 | ||
| #define LOCAL_PROBE_TIMEOUT_SEC 3L | ||
| #define LOCAL_PROBE_CONNECT_SEC 2L | ||
| #define LOCAL_REPROBE_MIN_SEC 15L | ||
|
|
||
| static const config_t *s_local_cfg; | ||
| static int s_local_unavailable; | ||
| static time_t s_local_reprobe_last_wall; | ||
| #ifdef SHELLCLAW_TEST | ||
| static const char *s_local_test_http_body; | ||
| static int s_local_test_skip_probe; | ||
|
|
@@ -184,6 +188,24 @@ static int local_chat(const provider_message_t *messages, size_t message_count, | |
| provider_set_error(response, "Local provider not initialized"); | ||
| return -1; | ||
| } | ||
| /* Init probes once, often before llama-server has loaded the model. | ||
| * Default fallback order puts local last, so router recovery (which | ||
| * only probes backends before the active index) never clears the flag. */ | ||
| if (s_local_unavailable) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probe is synchronous and repeats on every |
||
| const char *endpoint = config_provider_local_endpoint(s_local_cfg); | ||
| time_t now = time(NULL); | ||
| /* agent_run holds agent_lock while this probe runs synchronously; | ||
| * at most one probe per LOCAL_REPROBE_MIN_SEC while unavailable, | ||
| * else a down llama-server blocks the gateway/channel every turn. */ | ||
| int reprobe_due = s_local_reprobe_last_wall == (time_t)0 || | ||
| (unsigned long)(now - s_local_reprobe_last_wall) >= | ||
| (unsigned long)LOCAL_REPROBE_MIN_SEC; | ||
| if (reprobe_due) { | ||
| s_local_reprobe_last_wall = now; | ||
| if (endpoint && endpoint[0] != '\0' && provider_local_endpoint_reachable(endpoint)) | ||
| provider_local_recovery_probe_succeeded(); | ||
| } | ||
| } | ||
| if (s_local_unavailable) { | ||
| provider_set_error(response, "Local inference server unreachable"); | ||
| return -1; | ||
|
|
@@ -196,6 +218,7 @@ static void local_cleanup(void) | |
| { | ||
| s_local_cfg = NULL; | ||
| s_local_unavailable = 0; | ||
| s_local_reprobe_last_wall = (time_t)0; | ||
| } | ||
|
|
||
| #ifdef SHELLCLAW_TEST | ||
|
|
@@ -209,6 +232,7 @@ void local_provider_test_reset(void) | |
| s_local_test_http_body = NULL; | ||
| s_local_test_skip_probe = 0; | ||
| s_local_unavailable = 0; | ||
| s_local_reprobe_last_wall = (time_t)0; | ||
| } | ||
|
|
||
| void local_provider_test_set_http_response(const char *json_body) | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop stops at the first following message without
tool_use_id, which is right. Add a test for results followed by a plain user message and for a single result, so this boundary is locked.