diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 18:00:12 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 18:00:12 +0100 |
| commit | 8ae5bd48cf233315b5f36a7a6b39002a5e77f74b (patch) | |
| tree | 71c9b71f90f3cc64544dd506041468ee9bcbcda1 /src/main.rs | |
| parent | 0.6.2: resizing no longer duplicates the prompt (diff) | |
| download | agent686-8ae5bd48cf233315b5f36a7a6b39002a5e77f74b.tar.gz agent686-8ae5bd48cf233315b5f36a7a6b39002a5e77f74b.zip | |
0.7.0: resume shows where you left off; no approval for unparsable calls
- --continue prints the last answer, or the last reasoning block if there was none
- tool arguments are validated before prompting, so an empty bash call becomes an
error for the model instead of a blank approval
- empty placeholder tool calls are dropped and reported
- sessions tolerate invalid UTF-8 lines from a torn write
- AGENT686_DEBUG_STREAM=1 dumps SSE frames
Diffstat (limited to '')
| -rw-r--r-- | src/main.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 91d54da..45ca8c6 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -195,6 +195,7 @@ fn run(args: Args) { | |||
| 195 | } | 195 | } |
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 198 | let resuming = args.session.is_some() || args.continue_last; | ||
| 198 | let (mut session, mut history) = match open_session(&cfg, args.session, args.continue_last) { | 199 | let (mut session, mut history) = match open_session(&cfg, args.session, args.continue_last) { |
| 199 | Ok(pair) => pair, | 200 | Ok(pair) => pair, |
| 200 | Err(message) => { | 201 | Err(message) => { |
| @@ -205,6 +206,9 @@ fn run(args: Args) { | |||
| 205 | cfg.session = session.id.clone(); | 206 | cfg.session = session.id.clone(); |
| 206 | 207 | ||
| 207 | warn_if_moved(&session); | 208 | warn_if_moved(&session); |
| 209 | if resuming { | ||
| 210 | print_last_reply(&session.id); | ||
| 211 | } | ||
| 208 | if !session.version.is_empty() && session.version != env!("CARGO_PKG_VERSION") { | 212 | if !session.version.is_empty() && session.version != env!("CARGO_PKG_VERSION") { |
| 209 | eprintln!( | 213 | eprintln!( |
| 210 | "agent686: this session was written by {}; the prompt and tool schemas may \ | 214 | "agent686: this session was written by {}; the prompt and tool schemas may \ |
| @@ -647,3 +651,42 @@ fn render_message(message: &Value, color: bool) -> String { | |||
| 647 | other => format!("[{other}]\n"), | 651 | other => format!("[{other}]\n"), |
| 648 | } | 652 | } |
| 649 | } | 653 | } |
| 654 | |||
| 655 | /// On resume, show where the conversation left off: the last answer, or the last | ||
| 656 | /// reasoning when the model never produced content. Only on a terminal, so piped | ||
| 657 | /// runs stay clean. | ||
| 658 | fn print_last_reply(id: &str) { | ||
| 659 | if !std::io::stdout().is_terminal() { | ||
| 660 | return; | ||
| 661 | } | ||
| 662 | let Some(reply) = session::last_reply(id) else { | ||
| 663 | return; | ||
| 664 | }; | ||
| 665 | let text = if reply.content.trim().is_empty() { | ||
| 666 | reply.reasoning.trim() | ||
| 667 | } else { | ||
| 668 | reply.content.trim() | ||
| 669 | }; | ||
| 670 | if text.is_empty() { | ||
| 671 | return; | ||
| 672 | } | ||
| 673 | |||
| 674 | let lines: Vec<&str> = text.lines().collect(); | ||
| 675 | let limit = 20; | ||
| 676 | println!(); | ||
| 677 | println!("{}", style("2", "── where you left off ──", true)); | ||
| 678 | for line in lines.iter().take(limit) { | ||
| 679 | println!("{line}"); | ||
| 680 | } | ||
| 681 | if lines.len() > limit { | ||
| 682 | println!( | ||
| 683 | "{}", | ||
| 684 | style( | ||
| 685 | "2", | ||
| 686 | &format!("… {} more line(s); `agent686 --show` for the transcript", lines.len() - limit), | ||
| 687 | true | ||
| 688 | ) | ||
| 689 | ); | ||
| 690 | } | ||
| 691 | println!(); | ||
| 692 | } | ||
