Skip to content

feat(guidelines): add consistency-fast pipeline, simplify configuration - #300

Open
evduester wants to merge 9 commits into
mainfrom
feat/consistency-fast-guidelines
Open

feat(guidelines): add consistency-fast pipeline, simplify configuration#300
evduester wants to merge 9 commits into
mainfrom
feat/consistency-fast-guidelines

Conversation

@evduester

@evduester evduester commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a new consistency-fast guideline generation method: instead of
    resampling each trajectory step and scoring uncertainty externally (the
    existing accurate pipeline), the guideline-generation LLM self-judges
    each step's confidence in the same call that produces guidelines — same
    cost profile as standard mode, no extra LLM calls. Controlled by
    EVOLVE_CONSISTENCY_METHOD (fast / accurate), which now defaults to
    fast since most volume use cases can't afford resampling on every
    trajectory.
  • Renames EVOLVE_GUIDELINES_MODE values regular/bothstandard/all
    for clearer terminology. Breaking change, no backward-compat aliases.
  • Moves the three accurate-method uncertainty tuning knobs
    (high_uncertainty_threshold, low_uncertainty_threshold,
    skip_on_no_uncertainty) from env vars into agent_config.yaml, next to
    the pipeline's other advanced settings, since they only apply to that one
    method.
  • Fixes two bugs found during live testing:
    • Resampling silently dropped the configured LLM provider whenever a step
      recorded its own model, causing misrouted/failed calls.
    • Uncertainty labels claimed HIGH UNCERTAINTY for steps that only
      cleared the low threshold, not the high one — now correctly labeled
      ELEVATED UNCERTAINTY.
  • Rewrites the accurate-method prompt's analysis instructions, which had
    drifted into asking the LLM to re-judge step confidence from scratch
    (redundant with the uncertainty scores it's already given) and referenced
    an undefined "weak steps" term.
  • Documents EVOLVE_CONSISTENCY_METHOD, which had shipped without docs.

Test plan

  • pytest tests/unit — 635 passed
  • ruff check / ruff format --check — clean
  • mypy on touched modules — clean
  • mkdocs build --strict — no new warnings
  • e2e suite (test_e2e_consistency_pipeline.py,
    test_e2e_mcp_consistency.py, test_e2e_smolagent_mcp.py) against a
    real LLM backend — 12/12 real test cases pass (fast, accurate, and
    all mode, including the new default all+fast combination); the
    6 [asyncio-milvus] parametrizations error at fixture setup on a
    pre-existing, unrelated missing pymilvus dependency in this
    environment
  • Manually compared standard / consistency-accurate /
    consistency-fast guideline output on deliberately-confused agent
    trajectories

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

Summary by CodeRabbit

  • New Features

    • Added standard, consistency, and all guideline modes.
    • Added configurable fast and accurate consistency-generation methods, with fast as the default.
    • Added fast generation without trajectory resampling.
    • Improved handling of tool calls in agent trajectories.
  • Bug Fixes

    • Improved provider routing, uncertainty indicators, metadata, and sync completion reporting.
  • Documentation

    • Updated configuration, Phoenix sync, tracing, and tutorial guides with the new options.

Resampling-based consistency guidelines (now "accurate") cost N extra LLM
calls per trajectory, too expensive to run at volume. Adds "fast": the
guideline-generation LLM self-judges each step's confidence in the same
call that produces guidelines, at standard-mode cost. EVOLVE_CONSISTENCY_METHOD
selects between them and now defaults to fast, since most volume use cases
can't afford resampling on every trajectory.

Also, while wiring this up:
- Renames guidelines_mode regular/both -> standard/all for clearer
  terminology (breaking, no backward-compat aliases).
- Moves the three accurate-method uncertainty tuning knobs
  (high/low threshold, skip_on_no_uncertainty) from env vars into
  agent_config.yaml, alongside the pipeline's other advanced settings,
  since they only apply to the accurate method.
- Fixes two bugs surfaced during live testing: resampling silently
  dropped the configured LLM provider whenever a step recorded its own
  model, and uncertainty labels claimed "HIGH" for steps that only
  cleared the low threshold.
- Rewrites the accurate-method prompt's analysis instructions, which had
  drifted into asking the LLM to re-judge step confidence from scratch
  (redundant with the uncertainty scores it's already given) and
  referenced an undefined "weak steps" term.
- Documents EVOLVE_CONSISTENCY_METHOD, previously shipped without docs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@evduester
evduester requested a review from visahak July 31, 2026 16:56
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d3c3185-5ae9-415a-a903-06afc5c74682

📥 Commits

Reviewing files that changed from the base of the PR and between bc65272 and cbdf427.

📒 Files selected for processing (2)
  • altk_evolve/llm/guidelines/guidelines.py
  • tests/unit/test_guidelines.py

📝 Walkthrough

Walkthrough

Phoenix sync now uses standard, consistency, and all modes. Consistency generation supports fast and accurate methods. Settings, integrations, prompts, documentation, trajectory parsing, and tests were updated.

Changes

Guideline generation modes

Layer / File(s) Summary
Configuration and CLI contracts
altk_evolve/cli/cli.py, altk_evolve/config/guidelines.py, docs/guides/*, docs/tutorials/guidelines-loop.md, .env.example
The CLI and settings accept the renamed modes and consistency methods. Invalid values use defaults.
Consistency analysis and fast generation
altk_evolve/llm/guidelines/consistency_guidelines.py, altk_evolve/llm/guidelines/consistency_analyzer/*, altk_evolve/llm/guidelines/prompts/*, altk_evolve/llm/guidelines/guidelines.py
The accurate pipeline adds uncertainty handling and provider forwarding. The fast pipeline generates guidelines without resampling. Native assistant tool calls are parsed.
Phoenix and MCP integration
altk_evolve/sync/phoenix_sync.py, altk_evolve/frontend/mcp/mcp_server.py, tests/unit/test_mcp_server.py, tests/unit/test_phoenix_sync.py, tests/unit/test_conflict_resolution.py
Phoenix and MCP dispatch the selected pipeline and record standard, consistency, or consistency-fast metadata.
Pipeline validation and test isolation
tests/unit/test_consistency_guidelines.py, tests/unit/test_guidelines.py, tests/e2e/test_e2e_*.py
Tests cover fast and accurate execution, mode dispatch, metadata, completion handling, environment restoration, artifact isolation, and native tool-call parsing.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant GuidelinesSettings
  participant PhoenixSync
  participant MCPServer
  participant ConsistencyGenerator
  CLI->>GuidelinesSettings: set guidelines_mode and consistency_method
  PhoenixSync->>ConsistencyGenerator: select fast or accurate method
  MCPServer->>ConsistencyGenerator: generate consistency guidelines
  ConsistencyGenerator-->>PhoenixSync: return guidelines and generation metadata
  PhoenixSync-->>MCPServer: persist standard or consistency results
Loading

Possibly related issues

Possibly related PRs

Suggested reviewers: visahak, gaodan-fang

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.60% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main changes: adding the consistency-fast pipeline and simplifying guideline configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/consistency-fast-guidelines

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (4)
tests/unit/test_consistency_guidelines.py (1)

560-566: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use a normal json import in the helper.

__import__("json").dumps(payload) is hard to read. Import json at module scope or inside the helper.

♻️ Proposed change
     def _mock_completion_response(self, payload: dict):
+        import json
         from unittest.mock import MagicMock
 
         response = MagicMock()
         response.choices = [MagicMock()]
-        response.choices[0].message.content = __import__("json").dumps(payload)
+        response.choices[0].message.content = json.dumps(payload)
         return response
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_consistency_guidelines.py` around lines 560 - 566, Update
_mock_completion_response to use a normal json import instead of dynamically
calling __import__("json"); add the import at module scope or within the helper,
then call json.dumps(payload) when assigning message.content.
altk_evolve/llm/guidelines/consistency_guidelines.py (1)

593-664: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting the shared completion and parse block.

_generate_fast_guideline_result repeats the constrained/unconstrained completion calls, clean_llm_response handling, and the JSON repair plus validation ladder from _generate_guideline_result (Lines 376-426). Only the prompt, the hook purpose, and the log text differ. Extract a helper that takes the rendered prompt and the purpose, then returns a GuidelineGenerationResult. This keeps future parsing fixes in one place.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@altk_evolve/llm/guidelines/consistency_guidelines.py` around lines 593 - 664,
Extract the duplicated completion, response cleaning, JSON repair, and
validation logic from _generate_fast_guideline_result and
_generate_guideline_result into a shared helper accepting the rendered prompt
and dispatch purpose, returning GuidelineGenerationResult. Preserve constrained
and unconstrained decoding behavior, empty-response handling, and each caller’s
existing purpose and log context while routing both functions through the
helper.
altk_evolve/frontend/mcp/mcp_server.py (1)

623-639: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider a shared method-dispatch helper.

altk_evolve/sync/phoenix_sync.py contains the same consistency_method == "fast" branch, the same deferred imports, and the same consistency-fast/consistency tag mapping. A single helper that returns the generator callable and the tag would keep the two entry points aligned when a third method is added.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@altk_evolve/frontend/mcp/mcp_server.py` around lines 623 - 639, The
consistency method dispatch in the guidelines flow duplicates the fast/default
branch, deferred imports, and tag mapping found in phoenix_sync.py. Extract a
shared helper that selects and returns the appropriate consistency generator
callable and its "consistency-fast" or "consistency" tag, then update both entry
points to use it so future methods remain aligned.
tests/e2e/test_e2e_mcp_consistency.py (1)

29-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated _guidelines_env context manager in two e2e test files. Both files define the same helper that mutates os.environ and reinitializes the guidelines_settings singleton. A future fix to the reload behavior must then be applied twice.

  • tests/e2e/test_e2e_mcp_consistency.py#L29-L51: move _guidelines_env into a shared module, for example tests/e2e/conftest.py, and import it here.
  • tests/e2e/test_e2e_smolagent_mcp.py#L32-L55: delete the local copy and import the shared helper.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/test_e2e_mcp_consistency.py` around lines 29 - 51, Move the
duplicated _guidelines_env context manager from
tests/e2e/test_e2e_mcp_consistency.py lines 29-51 into a shared helper in
tests/e2e/conftest.py, preserving its environment restoration and
guidelines_settings reinitialization behavior; delete the local copy from
tests/e2e/test_e2e_smolagent_mcp.py lines 32-55 and import the shared
_guidelines_env in both test files.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@altk_evolve/cli/cli.py`:
- Around line 545-548: Apply Ruff formatting to the consistency_method option
declaration in altk_evolve/cli/cli.py (lines 545-548), the validator warning
calls in altk_evolve/config/guidelines.py (lines 18-30), and the new patch(...)
expressions in tests/unit/test_phoenix_sync.py (lines 1287-1317). Run uv run
ruff format . and stage updated tracked files with git add -u.

In `@altk_evolve/llm/guidelines/prompts/generate_consistency_guidelines.jinja2`:
- Line 16: Correct the misspelled word “truely” in the guideline text near
“Generate only what's needed” to “truly,” without changing the surrounding
wording.

In `@docs/guides/guidelines.md`:
- Around line 23-24: Update the fast method description in the guidelines table
to remove references to repeated runs and clarify that it self-assesses within
the generation call, running once per generated subtask when segmentation
succeeds or once for an unsegmented trajectory.

In `@tests/e2e/test_e2e_consistency_pipeline.py`:
- Around line 424-425: Update the error-pattern check in the fast consistency
test to also recognize “called on trajectory with no steps” and
“generate_consistency_guidelines_fast called with empty messages” as LLM-side
failures, alongside the existing RateLimitError and budget-exceeded patterns, so
llm_error_occurred is set before the final assertion.

---

Nitpick comments:
In `@altk_evolve/frontend/mcp/mcp_server.py`:
- Around line 623-639: The consistency method dispatch in the guidelines flow
duplicates the fast/default branch, deferred imports, and tag mapping found in
phoenix_sync.py. Extract a shared helper that selects and returns the
appropriate consistency generator callable and its "consistency-fast" or
"consistency" tag, then update both entry points to use it so future methods
remain aligned.

In `@altk_evolve/llm/guidelines/consistency_guidelines.py`:
- Around line 593-664: Extract the duplicated completion, response cleaning,
JSON repair, and validation logic from _generate_fast_guideline_result and
_generate_guideline_result into a shared helper accepting the rendered prompt
and dispatch purpose, returning GuidelineGenerationResult. Preserve constrained
and unconstrained decoding behavior, empty-response handling, and each caller’s
existing purpose and log context while routing both functions through the
helper.

In `@tests/e2e/test_e2e_mcp_consistency.py`:
- Around line 29-51: Move the duplicated _guidelines_env context manager from
tests/e2e/test_e2e_mcp_consistency.py lines 29-51 into a shared helper in
tests/e2e/conftest.py, preserving its environment restoration and
guidelines_settings reinitialization behavior; delete the local copy from
tests/e2e/test_e2e_smolagent_mcp.py lines 32-55 and import the shared
_guidelines_env in both test files.

In `@tests/unit/test_consistency_guidelines.py`:
- Around line 560-566: Update _mock_completion_response to use a normal json
import instead of dynamically calling __import__("json"); add the import at
module scope or within the helper, then call json.dumps(payload) when assigning
message.content.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d8d67941-664e-4489-9ffe-e913301735b4

📥 Commits

Reviewing files that changed from the base of the PR and between 05f3641 and 15fb16e.

📒 Files selected for processing (21)
  • altk_evolve/cli/cli.py
  • altk_evolve/config/guidelines.py
  • altk_evolve/frontend/mcp/mcp_server.py
  • altk_evolve/llm/guidelines/consistency_analyzer/agent_config.yaml
  • altk_evolve/llm/guidelines/consistency_analyzer/resampling.py
  • altk_evolve/llm/guidelines/consistency_guidelines.py
  • altk_evolve/llm/guidelines/prompts/generate_consistency_guidelines.jinja2
  • altk_evolve/llm/guidelines/prompts/generate_consistency_guidelines_fast.jinja2
  • altk_evolve/sync/phoenix_sync.py
  • docs/guides/configuration.md
  • docs/guides/guidelines.md
  • docs/guides/low-code-tracing.md
  • docs/guides/phoenix-sync.md
  • docs/tutorials/guidelines-loop.md
  • tests/e2e/test_e2e_consistency_pipeline.py
  • tests/e2e/test_e2e_mcp_consistency.py
  • tests/e2e/test_e2e_smolagent_mcp.py
  • tests/unit/test_conflict_resolution.py
  • tests/unit/test_consistency_guidelines.py
  • tests/unit/test_mcp_server.py
  • tests/unit/test_phoenix_sync.py

Comment thread altk_evolve/cli/cli.py
Comment thread altk_evolve/llm/guidelines/prompts/generate_consistency_guidelines.jinja2 Outdated
Comment thread docs/guides/guidelines.md
Comment thread tests/e2e/test_e2e_consistency_pipeline.py Outdated
evduester and others added 2 commits July 31, 2026 14:57
Addresses CodeRabbit's docstring-coverage gate (was 56.86%, below the
80% threshold) by documenting the functions this PR added or modified
that lacked one — validators and format_trajectory_data in production
code, plus test methods that previously relied on descriptive names alone.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Fix "truely" -> "truly" typo in the accurate-method prompt.
- Correct the fast-method cost description in guidelines.md: it makes
  one LLM call per generated subtask (same cadence as standard mode),
  not always exactly one call per trajectory.
- Fast e2e test's LLM-error detection now also matches "called on
  trajectory with no steps" and "called with empty messages", matching
  the accurate tests' patterns — without this, a trajectory with no
  scorable steps would fail the test's final assertion even though the
  sync completed cleanly.

The formatting nitpick (cli.py/config/guidelines.py/test_phoenix_sync.py)
was already resolved by an earlier commit; `ruff format .` confirms no
changes needed across the repo.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@evduester
evduester requested a review from gaodan-fang August 3, 2026 14:10

@gaodan-fang gaodan-fang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review pass on the branch diff against main. These came out of an automated (Codex) review that I then verified by hand against the code; I've dropped its findings that turned out to be arguing with decisions your summary already documents, and confirmed the ones below.

The tool_calls one is the substantive find — I reproduced it, details inline. The other two inline notes are questions rather than defect claims.

One nit that has no diff line to hang off: .env.example:14 still reads

# EVOLVE_GUIDELINES_MODE=regular  # Options: regular, consistency, both

Given the intentional no-aliases rename, both regular and both there now hit coerce_invalid_mode and silently become standard. Anyone uncommenting that line gets a warning-level log and not the mode they asked for. It's the only stale reference to the old values left in tracked source — everything else is consistent.

To be explicit about what I am not flagging: the regular/bothstandard/all break and its lack of back-compat aliases both read as deliberate per your summary, so I've left them alone beyond that one stale comment.

Comment thread altk_evolve/llm/guidelines/consistency_guidelines.py
Comment thread altk_evolve/llm/guidelines/consistency_analyzer/resampling.py
Comment thread altk_evolve/config/guidelines.py
evduester and others added 4 commits August 4, 2026 13:26
.env.example still showed regular/both, which coerce_invalid_mode now
silently rewrites to standard since the rename has no back-compat aliases.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
EVOLVE_HIGH_UNCERTAINTY_THRESHOLD / EVOLVE_LOW_UNCERTAINTY_THRESHOLD /
EVOLVE_SKIP_ON_NO_UNCERTAINTY moved to agent_config.yaml, but
GuidelinesSettings' extra="ignore" meant a deployment still setting them
lost the values with no signal. Warn at settings-load time instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…_trajectory

Assistant messages using the Chat Completions/Phoenix shape (content: null,
tool_calls: [...]) fell through to the "skip empty assistant messages"
branch, silently dropping the tool call. Only the Agents SDK/Responses API
shape (content as a list of function_call items) was handled.

Since generate_consistency_guidelines_fast (now the default) builds its
prompt straight from this parser's steps_list, the self-judging LLM never
saw tool use at all for native-protocol traces — the ones with
trajectory["tools"] populated, which the accurate path treats as its
best-case input. generate_guidelines (standard mode) shared the same gap.

segment_trajectory calls the same parser and defines its step indices
relative to its steps_list, so fixing it here keeps both callers aligned
without touching the accurate path's separate _can_segment_trajectory guard.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… resampling

Resampling in accurate mode forwards EVOLVE_CUSTOM_LLM_PROVIDER for every
step regardless of the traced model, treating it as a single deployment-wide
routing setting. That setting also defaults to "openai" merely from
OPENAI_API_KEY/OPENAI_BASE_URL being present, not from an explicit operator
choice — so a Phoenix project mixing providers (e.g. claude-* and gpt-*
traces) can silently misroute non-OpenAI steps during accurate-mode
resampling. Documents the contract: set EVOLVE_CUSTOM_LLM_PROVIDER
explicitly per sync for mixed-provider namespaces, or use fast (the
default), which never resamples.

Also corrects the configuration reference table, which listed
EVOLVE_CUSTOM_LLM_PROVIDER's default as None — it's actually openai
whenever OPENAI_API_KEY/OPENAI_BASE_URL is set.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@altk_evolve/llm/guidelines/guidelines.py`:
- Around line 86-117: Update the native tool-call argument formatting in the
tool-call extraction block to verify that parsed args are a dictionary before
iterating with .items(). Route JSON arrays, scalars, None, and non-string
non-mapping arguments through the existing raw-argument fallback, while
preserving formatted output for dictionary arguments. Add regression coverage
for a JSON array and a non-string argument.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7244d7a6-dc4d-479a-8683-90103ba4f130

📥 Commits

Reviewing files that changed from the base of the PR and between 2b39cce and bc65272.

📒 Files selected for processing (8)
  • .env.example
  • altk_evolve/config/guidelines.py
  • altk_evolve/llm/guidelines/guidelines.py
  • altk_evolve/llm/guidelines/prompts/generate_consistency_guidelines.jinja2
  • docs/guides/configuration.md
  • docs/guides/guidelines.md
  • tests/e2e/test_e2e_consistency_pipeline.py
  • tests/unit/test_guidelines.py
🚧 Files skipped from review as they are similar to previous changes (5)
  • docs/guides/configuration.md
  • docs/guides/guidelines.md
  • altk_evolve/llm/guidelines/prompts/generate_consistency_guidelines.jinja2
  • altk_evolve/config/guidelines.py
  • tests/e2e/test_e2e_consistency_pipeline.py

Comment thread altk_evolve/llm/guidelines/guidelines.py
…on-dict args

json.loads(args_str) can validly return a list, scalar, or None (e.g.
arguments="[1, 2, 3]"), and args.items() on those raises AttributeError,
which the except (JSONDecodeError, TypeError) clause doesn't catch. That
aborted parsing instead of falling back to the raw-argument string like
every other malformed-input case here does.

Reject non-dict args explicitly so they route through the same fallback.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@evduester
evduester requested a review from gaodan-fang August 4, 2026 20:55

@gaodan-fang gaodan-fang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 06b32cd. Verified each fix by running it rather than reading it — three of the four are solid, and one is 90% there with a remaining edge I'd want closed before merge.

Verified fixed:

  • .env.example / docs (dbabe95) — stale regular/both gone; the EVOLVE_CUSTOM_LLM_PROVIDER table entry now documents the implicit-default behavior, which is a better outcome than what I asked for.
  • Removed uncertainty env vars (ea5d895) — confirmed the warning fires with EVOLVE_HIGH_UNCERTAINTY_THRESHOLD / EVOLVE_SKIP_ON_NO_UNCERTAINTY set, and stays silent when unset. Names the YAML keys and the config_path= route, so an operator hitting it knows where to go. Resolves my note.
  • Mixed-provider resampling (bc65272) — the docs answer stands on its own: it states the deployment-wide contract explicitly, names the implicit openai default as the trigger, and gives two concrete outs. I checked the fast recommendation holds — generate_consistency_guidelines_fast has no resample_trajectory call, so there is genuinely no routing step to misroute. Treating this as a documented design decision rather than a bug is the right call; resolved.
  • Malformed tool-call arguments (06b32cd) — probed JSON arrays, bare scalars, invalid JSON, pre-parsed dicts, null, and a tool_calls entry with no function key at all. None crash; each falls back to raw display or unknown. Good defensive follow-up, and it wasn't something I'd flagged.

Still open: one inline comment on guidelines.py — the native tool-call fix is elif-gated on content, so turns carrying both text and tool_calls still lose the call. Details and a repro there.

Checks on my end: pytest tests/unit → 660 passed, 8 skipped; ruff check and ruff format --check clean. (The two collection errors I hit were from unrelated untracked files in my own working tree, not this branch.)

Comment thread altk_evolve/llm/guidelines/guidelines.py
…o carry text

An Anthropic-shape turn `[{"type":"text",...},{"type":"tool_use",...}]`
collapses into a single Chat Completions message with both a non-empty
`content` string and `tool_calls`. The text-content and tool_calls
branches were chained with elif, so the tool call was silently dropped
whenever text content was also present, yielding zero captured
function_calls despite tool use.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@evduester
evduester requested a review from gaodan-fang August 6, 2026 13:38
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.

2 participants