Skip to content

Make the Ollama provider work; fix the AI prompt and dedupe group-commit (stack 2/5) - #43

Closed
martient wants to merge 2 commits into
claude/ai-agents-capabilities-report-fgpp3p-v2from
claude/ai-agents-capabilities-report-fgpp3p-ai-fixes
Closed

martient wants to merge 2 commits into
claude/ai-agents-capabilities-report-fgpp3p-v2from
claude/ai-agents-capabilities-report-fgpp3p-ai-fixes

Conversation

@martient

@martient martient commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #42. Resolves the audit's AI findings.

The Ollama provider has never worked

Two independent bugs, either of which is fatal:

  • stream was never set. /api/chat defaults to stream: true, so every response was newline-delimited events and resp.json::<ResponseBody>() failed. Every --ai-provider ollama run ended in LlmError::Parse and silently fell back to the default message. Now sends stream: false.
  • format was nested under options, where Ollama does not read it, so JSON mode was a no-op. It is a top-level field, and now carries a JSON Schema for AiCommitSuggestion rather than the bare string "json" — constrained decoding instead of a polite request.

The default AI path had nothing to work with

Unless --ai-allow-sensitive was set, the prompt contained the group name, the default type, and an instruction to improve the description "without revealing code or filenames". The model was asked to improve something it could not see.

It now sends a redacted shape: file count, extension histogram, and top-level areas only.

Change shape (no filenames or content): 7 file(s); types: .rs x6, .toml x1; areas: src, tests

No filename, no path below the first segment, and no file content is sent in either mode — --ai-allow-sensitive controls paths, not content, which the docs previously got wrong in both directions.

Correction to the audit

P0-4 was wrong and is withdrawn. It claimed --ai was silently ignored in --mode apply. It never was — the apply arm has its own AI block. The error came from misreading a grep piped through awk 'NR>=530', whose renumbered output was taken for plan-arm line numbers.

The real problem there is what made that misreading possible: plan and apply carried byte-identical copies of the group-building loop and the ~150-line AI block. Both are now extracted into build_groups() and ai_user_prompt() and shared.

Removals

--ai-diff-lines-per-file (declared, documented, accepted, never read), LlmError::_Timeout, and the commented-out LlmProvider enum.

Verification

Request bodies are now built by pure functions with unit tests, so the wire format is verifiable without a network call — 6 tests covering stream, format placement, schema shape, and sampling options. Full suite 374 passed; fmt and clippy -D warnings clean. The two pre-existing failures noted in #42 are unchanged.

@martient
martient added this pull request to stack #48 September 20, 2026 17:40
@martient martient self-assigned this Sep 20, 2026
@martient martient added the bug Something isn't working label Sep 20, 2026
Four real defects from the agent audit, plus one withdrawn finding.

- Ollama requests now set `stream: false`. The endpoint defaults to
  streaming, so every previous call received newline-delimited events and
  died in LlmError::Parse before silently falling back to the default
  message. The provider has never worked.
- `format` moves from `options` to the top level, where Ollama reads it,
  and now carries a JSON Schema for AiCommitSuggestion rather than the
  string "json", so decoding is constrained instead of merely requested.
- The default (non-sensitive) AI path sent only the group name and an
  instruction not to reveal anything, leaving the model nothing to work
  from. It now sends a redacted shape summary: file count, extension
  histogram and top-level areas. No filename, no path below the first
  segment, and no file content is sent in either mode.
- `--ai-diff-lines-per-file` was declared, documented and accepted but
  never read. Removed, along with the dead LlmError::_Timeout variant and
  the commented-out LlmProvider enum.

The audit's P0-4 ("--ai silently ignored in --mode apply") was wrong and
is withdrawn: the apply arm has always had its own AI block. The real
problem there was duplication -- plan and apply carried identical copies
of group building and the AI block -- which is what made the misreading
possible. Both are extracted into build_groups() and ai_user_prompt().

Request bodies are now built by pure functions with unit tests, so the
wire format is verifiable without a network call.
The pull_request trigger filtered on branches: ["*"], and in Actions
branch filters `*` matches everything except `/`. Any pull request whose
base branch contains a slash therefore matched nothing and ran no checks
at all -- silently, since a workflow that does not trigger looks the same
as one with nothing to report.

That covers every stacked pull request in this series (all but the first
target a claude/... base and have zero check runs), and would equally
cover anything based on a feat/ or fix/ prefix.

`**` matches across slashes, which is what the filter meant.

Copy link
Copy Markdown
Owner Author

Superseded by #49, which carries these commits unchanged. Closing — see #42 for why the stack was collapsed.


Generated by Claude Code

@martient martient closed this Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants