Skip to content
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

Graceful Continuation After Tool Misuse #313

Closed
bogzbonny opened this issue Feb 19, 2025 · 1 comment
Closed

Graceful Continuation After Tool Misuse #313

bogzbonny opened this issue Feb 19, 2025 · 1 comment

Comments

@bogzbonny
Copy link
Contributor

bogzbonny commented Feb 19, 2025

Currently if the tools are misused by the agent, and the number of tool call retries is reached swiftide shuts down the agent and stops kwaak.

Issues:

  • This is a non-graceful shutdown which is non-recoverable, it prevents continuation with user input due to an imbalance in tool_use and tool_result blocks. Here is what occurs after a non-graceful shutdown:
> writing file `src/git/github.rs`
ℹ Failed to handle command: arguments for tool failed to parse: missing field content at line 1 column 33: missing field content at line 1 column 33

user: attempt to continue

ℹ Failed to handle command: llm returned an error: malformed request: {"type":"error","error":{"type":"invalid_request_error","message":"messages.24: 
Did not find 1 tool_result block(s) at the beginning of this message. Messages following tool_use blocks must begin with a matching number of
tool_result blocks."}}
  • Ideally kwaak should really attempt to continue, discarding the most recent call and gracefully continuing.

Side NOTE: Anthropic seems to be bad at using the write_file tool this comes up sometimes. It seems to do much better with write file by line number

@timonv
Copy link
Member

timonv commented Feb 26, 2025

I think this is issue is resolved now. Anthropic had trouble with the summarize step at times when there was no message, but there was a tool call in the message list. This is fixed, haven't encountered any issues after testing with 3.7 yesterday.

@timonv timonv closed this as completed Feb 26, 2025
timonv pushed a commit to bosun-ai/swiftide that referenced this issue Mar 1, 2025
Ensure tool calls and responses are always balanced, even when the tool retry limit is reached
bosun-ai/kwaak#313
timonv pushed a commit to bosun-ai/swiftide that referenced this issue Mar 5, 2025
## 🤖 New release

* `swiftide-core`: 0.21.1 -> 0.22.0 (✓ API compatible changes)
* `swiftide-macros`: 0.21.1 -> 0.22.0
* `swiftide-agents`: 0.21.1 -> 0.22.0 (✓ API compatible changes)
* `swiftide-indexing`: 0.21.1 -> 0.22.0 (✓ API compatible changes)
* `swiftide-integrations`: 0.21.1 -> 0.22.0 (⚠ API breaking changes)
* `swiftide-query`: 0.21.1 -> 0.22.0 (✓ API compatible changes)
* `swiftide`: 0.21.1 -> 0.22.0 (✓ API compatible changes)

### ⚠ `swiftide-integrations` breaking changes

```text
--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_missing.ron

Failed in:
  enum swiftide_integrations::groq::GroqBuilderError, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/groq/mod.rs:23
  enum swiftide_integrations::openai::OpenAIBuilderError, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/openai/mod.rs:38
  enum swiftide_integrations::groq::OptionsBuilderError, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/groq/mod.rs:46

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_missing.ron

Failed in:
  struct swiftide_integrations::groq::GroqBuilder, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/groq/mod.rs:23
  struct swiftide_integrations::openai::OpenAIBuilder, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/openai/mod.rs:38
  struct swiftide_integrations::groq::OptionsBuilder, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/groq/mod.rs:46
  struct swiftide_integrations::groq::Groq, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/groq/mod.rs:25
  struct swiftide_integrations::openai::OpenAI, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/openai/mod.rs:40
  struct swiftide_integrations::groq::Options, previously in file /tmp/.tmp04qAim/swiftide-integrations/src/groq/mod.rs:48
```

<details><summary><i><b>Changelog</b></i></summary><p>







## `swiftide`

<blockquote>

##
[0.22.0](v0.21.1...v0.22.0)
- 2025-03-03

### New features

-
[a754846](a754846)
*(agents)* Implement Serialize and Deserialize for chat messages

````text
Persist, retry later, evaluate it completions in a script, you name it.
````

-
[0a592c6](0a592c6)
*(indexing)* Add `iter()` for file loader
([#655](#655))

````text
Allows playing with the iterator outside of the stream.

  Relates to bosun-ai/kwaak#337
````

-
[57116e9](57116e9)
Groq ChatCompletion
([#650](#650))

````text
Use the new generics to _just-make-it-work_.
````

-
[4fd3259](4fd3259)
Continue Agent on Tool Failure
([#628](#628))

````text
Ensure tool calls and responses are always balanced, even when the tool retry limit is reached
  bosun-ai/kwaak#313
````

### Miscellaneous

- [0000000](0000000) Update
Cargo.toml dependencies


**Full Changelog**:
0.21.1...0.22.0
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
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

No branches or pull requests

2 participants