Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable Phonton CLI release changes should be documented here.

This project follows pre-1.0 SemVer: minor versions may still include breaking changes while the public API and CLI surface settle.

## 0.25.2 - Claude 5.5 models work with an Anthropic key

### Fixed

- [fixed] With an Anthropic key, goals failed with `anthropic response
missing content[0].text` whenever the model thought before answering.
Claude Sonnet 5.5, Opus 5.5 and Haiku 5.5 think by default, so a reply can
start with a `thinking` block. Phonton now reads every text block and skips
thinking blocks. A reply with no text reports the API's `stop_reason`.

## 0.25.1 - Local runs survive a busy laptop

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<p align="center">
<a href="https://github.com/phonton-dev/phonton-cli/actions/workflows/ci.yml"><img alt="CI Status" src="https://github.com/phonton-dev/phonton-cli/actions/workflows/ci.yml/badge.svg"></a>
<a href="https://github.com/phonton-dev/phonton-cli/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/phonton-dev/phonton-cli?style=flat&label=stars&color=ff69b4"></a>
<img alt="release" src="https://img.shields.io/badge/release-v0.25.1--beta-6c63ff">
<img alt="release" src="https://img.shields.io/badge/release-v0.25.2--beta-6c63ff">
<img alt="license" src="https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue">
</p>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phonton-cli",
"version": "0.25.1",
"version": "0.25.2",
"description": "Local-first ADE CLI for planned, verified, reviewable code changes.",
"license": "MIT OR Apache-2.0",
"homepage": "https://github.com/phonton-dev/phonton-cli#readme",
Expand Down
2 changes: 1 addition & 1 deletion phonton-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "phonton-cli"
version = "0.25.1"
version = "0.25.2"
edition.workspace = true
license.workspace = true
repository.workspace = true
Expand Down
40 changes: 35 additions & 5 deletions phonton-providers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,19 @@ fn native_image_attachments(attachments: &[PromptAttachment]) -> Vec<&PromptAtta
.collect()
}

/// Joins the `text` blocks of a Messages response. Claude 5.x models think
/// by default, so a `thinking` block can come before the text.
fn anthropic_response_text(resp: &Value) -> Option<String> {
let texts: Vec<&str> = resp
.get("content")?
.as_array()?
.iter()
.filter(|block| block.get("type").and_then(Value::as_str) == Some("text"))
.filter_map(|block| block.get("text").and_then(Value::as_str))
.collect();
(!texts.is_empty()).then(|| texts.concat())
}

fn anthropic_user_content(user: &str, attachments: &[PromptAttachment]) -> Value {
let images = native_image_attachments(attachments);
if images.is_empty() {
Expand Down Expand Up @@ -1199,11 +1212,13 @@ impl Provider for AnthropicProvider {
.await
.map_err(|e| ProviderError::ParseFail(e.to_string()))?;

let content = resp
.pointer("/content/0/text")
.and_then(Value::as_str)
.ok_or_else(|| anyhow!("anthropic response missing content[0].text"))?
.to_string();
let content = anthropic_response_text(&resp).ok_or_else(|| {
let stop = resp
.get("stop_reason")
.and_then(Value::as_str)
.unwrap_or("unknown");
anyhow!("anthropic response has no text block (stop_reason: {stop})")
})?;
let usage = resp
.get("usage")
.ok_or_else(|| anyhow!("anthropic response missing usage"))?;
Expand Down Expand Up @@ -1833,6 +1848,21 @@ impl Provider for OllamaProvider {
mod tests {
use super::*;

#[test]
fn anthropic_text_skips_leading_thinking_block() {
let resp = json!({ "content": [
{ "type": "thinking", "thinking": "", "signature": "sig" },
{ "type": "text", "text": "--- a/x\n" },
{ "type": "text", "text": "+++ b/x\n" }
]});
assert_eq!(
anthropic_response_text(&resp).as_deref(),
Some("--- a/x\n+++ b/x\n")
);
let thinking_only = json!({ "content": [{ "type": "thinking", "thinking": "" }] });
assert_eq!(anthropic_response_text(&thinking_only), None);
}

#[test]
fn semantic_only_leaves_prompt_untouched() {
let s = build_system_prompt("base", &[SliceOrigin::Semantic, SliceOrigin::Semantic]);
Expand Down
45 changes: 45 additions & 0 deletions release-notes/v0.25.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# phonton-cli v0.25.2 — Claude 5.5 models work with an Anthropic key

With an Anthropic key, 0.25.1 could fail a goal with
`anthropic response missing content[0].text`. Claude Sonnet 5.5, Opus 5.5
and Haiku 5.5 think by default, so a reply can open with a `thinking` block
before the text, and Phonton read only the first block. Sonnet 5.5 and
Opus 5.5 are Phonton's default Anthropic models for its standard and
frontier tiers, so this hit goals whenever one of them chose to think.

## Every text block is read

Phonton now joins the `text` blocks of a reply and skips `thinking` blocks.
A reply with no text at all, for example one that spent its whole
`max_tokens` budget thinking, now fails with the API's `stop_reason` instead
of a missing-field error.

## Verified

- A regression test covers a reply that opens with a `thinking` block and a
reply that has no text.
- Against the live API, `claude-sonnet-5-5` answered a short coding prompt
with a `thinking` block followed by the text.
- On 0.25.1, an Aider Polyglot JavaScript exercise failed at a model call with
this error. On 0.25.2 the same exercise got text back from every model call,
and the Rust exercise `luhn-from` ended review-ready on Sonnet 5.5 with its
tests passing.
- `cargo fmt`, `cargo clippy` with `-D warnings`, the workspace tests in CI,
the release build, `phonton doctor`, and `phonton doctor --provider` against
Anthropic all pass.

## Still limited

With a cloud key, Phonton verifies changes with cargo checks and tests and a
package's `npm test` script. For other stacks, Python included, a goal stops
with "Verification not run" instead of applying an unchecked change. Local
runs (`phonton goal --local`) take explicit `--check` commands.

## Install

```text
npm install -g phonton-cli
```

Or download a binary from GitHub Releases, or
`cargo install --git https://github.com/phonton-dev/phonton-cli phonton-cli --locked`.
Loading