OpenDevin / OpenDevin

🐚 OpenDevin: Code Less, Make More
https://docs.all-hands.dev/
MIT License
28.47k stars 3.26k forks source link

[Bug]: MaxCharsExceedError using version I downloaded last night #2288

Open FellowTraveler opened 1 month ago

FellowTraveler commented 1 month ago

Is there an existing issue for the same bug?

Describe the bug

This isn't a problem for me but I just thought you'd want to know. I was using OpenDevin to help me document / diagram C++ header files, going through them one by one, when it hit this MaxCharsExceedError.

Current OpenDevin version

I downloaded the docker last night.

opendevin-app-20240605050520
ghcr.io/opendevin/opendevin:0.6
cda48b730ecd5d86de683a45733003a8590e80ec889dd0951255b40dc89449c4

Installation and Configuration

I just ran the docker per the readme.md instructions.

Model and Agent

-Model: OpenAI GPT4o -Agent: Default, which I think is CodeAct.

Operating System

I'm sure it's running in linux in that docker, but my laptop is a Silicon Mac (M3 Max).

Reproduction Steps

Grab the opentxs library from github and tell the agent to start going through the headers in the include folder, and tell it to produce concise summaries and mermaid diagrams for everything. Then it will do the headers one by one, and you can keep prompting it to continue until you spend about $20 on the OpenAI API. Then the error will occur. P.S. I had to restart it once or twice, which is why the log only says $6. But trust me, you aren't getting off that cheap.

Logs, Errors, Screenshots, and Additional Context

2024-06-05 11:39:59 ==============
2024-06-05 11:39:59 CodeActAgent LEVEL 0 STEP 42
2024-06-05 11:39:59 
2024-06-05 11:40:06 16:40:06 - opendevin:INFO: llm.py:229 - Cost: 0.29 USD | Accumulated Cost: 6.62 USD
2024-06-05 11:40:06 16:40:06 - ACTION
2024-06-05 11:40:06 **CmdRunAction**
2024-06-05 11:40:06 THOUGHT: Let's proceed by examining the next file in the `opentxs/include/opentxs/api/crypto` directory. We'll move on to `Seed.hpp`.
2024-06-05 11:40:06 COMMAND:
2024-06-05 11:40:06 cat opentxs/include/opentxs/api/crypto/Seed.hpp
2024-06-05 11:40:07 16:40:07 - OBSERVATION
2024-06-05 11:40:07 **CmdOutputObservation (exit code=0)**
2024-06-05 11:40:07 // Copyright (c) 2010-2024 The Open-Transactions developers
2024-06-05 11:40:07 // This Source Code Form is subject to the terms of the Mozilla Public
2024-06-05 11:40:07 // License, v. 2.0. If a copy of the MPL was not distributed with this
2024-06-05 11:40:07 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
2024-06-05 11:40:07 
2024-06-05 11:40:07 #pragma once
2024-06-05 11:40:07 
2024-06-05 11:40:07 #include <cstdint>
2024-06-05 11:40:07 #include <string_view>
2024-06-05 11:40:07 #include <tuple>
2024-06-05 11:40:07 
2024-06-05 11:40:07 #include "opentxs/Export.hpp"
2024-06-05 11:40:07 #include "opentxs/Time.hpp"
2024-06-05 11:40:07 #include "opentxs/Types.hpp"
2024-06-05 11:40:07 #include "opentxs/blockchain/crypto/Types.hpp"
2024-06-05 11:40:07 #include "opentxs/crypto/Types.hpp"
2024-06-05 11:40:07 #include "opentxs/crypto/asymmetric/Types.hpp"
2024-06-05 11:40:07 #include "opentxs/util/Allocator.hpp"
2024-06-05 11:40:07 #include "opentxs/util/Container.hpp"
2024-06-05 11:40:07 #include "opentxs/util/Numbers.hpp"
2024-06-05 11:40:07 
2024-06-05 11:40:07 // NOLINTBEGIN(modernize-concat-nested-namespaces)
2024-06-05 11:40:07 namespace opentxs
2024-06-05 11:40:07 {
2024-06-05 11:40:07 namespace api
2024-06-05 11:40:07 {
2024-06-05 11:40:07 namespace crypto
2024-06-05 11:40:07 {
2024-06-05 11:40:07 namespace internal
2024-06-05 11:40:07 {
2024-06-05 11:40:07 class Seed;
2024-06-05 11:40:07 }  // namespace internal
2024-06-05 11:40:07 }  // namespace crypto
2024-06-05 11:40:07 }  // namespace api
2024-06-05 11:40:07 
2024-06-05 11:40:07 namespace crypto
2024-06-05 11:40:07 {
2024-06-05 11:40:07 namespace asymmetric
2024-06-05 11:40:07 {
2024-06-05 11:40:07 namespace key
2024-06-05 11:40:07 {
2024-06-05 11:40:07 class HD;
2024-06-05 11:40:07 class Secp256k1;
2024-06-05 11:40:07 }  // namespace key
2024-06-05 11:40:07 }  // namespace asymmetric
2024-06-05 11:40:07 
2024-06-05 11:40:07 namespace symmetric
2024-06-05 11:40:07 {
2024-06-05 11:40:07 class Key;
2024-06-05 11:40:07 }  // namespace symmetric
2024-06-05 11:40:07 
2024-06-05 11:40:07 class Seed;
2024-06-05 11:40:07 }  // namespace crypto
2024-06-05 11:40:07 
2024-06-05 11:40:07 namespace identifier
2024-06-05 11:40:07 {
2024-06-05 11:40:07 class Generic;
2024-06-05 11:40:07 }  // namespace identifier
2024-06-05 11:40:07 
2024-06-05 11:40:07 class PasswordPrompt;
2024-06-05 11:40:07 class Secret;
2024-06-05 11:40:07 }  // namespace opentxs
2024-06-05 11:40:07 // NOLINTEND(modernize-concat-nested-namespaces)
2024-06-05 11:40:07 
2024-06-05 11:40:07 namespace opentxs::api::crypto
2024-06-05 11:40:07 {
2024-06-05 11:40:07 /**
2024-06-05 11:40:07  The api::crypto::Seed API contains various seed-related crypto functions.
2024-06-05 11:40:07  */
2024-06-05 11:40:07 class OPENTXS_EXPORT Seed
2024-06-05 11:40:07 {
2024-06-05 11:40:07 public:
2024-06-05 11:40:07     virtual auto AccountChildKey(
2024-06-05 11:40:07         const ReadView& path,
2024-06-05 11:40:07         const opentxs::blockchain::crypto::Bip44Subchain subchain,
2024-06-05 11:40:07         const opentxs::crypto::Bip32Index index,
2024-06-05 11:40:07         const PasswordPrompt& reason) const
2024-06-05 11:40:07         -> opentxs::crypto::asymmetric::key::HD = 0;
2024-06-05 11:40:07     virtual auto AllowedLanguages(
2024-06-05 11:40:07         const opentxs::crypto::SeedStyle type) const noexcept -> const
2024-06-05 11:40:07         UnallocatedMap<opentxs::crypto::Language, std::string_view>& = 0;
2024-06-05 11:40:07     virtual auto AllowedSeedStrength(
2024-06-05 11:40:07         const opentxs::crypto::SeedStyle type) const noexcept -> const
2024-06-05 11:40:07         UnallocatedMap<opentxs::crypto::SeedStrength, std::string_view>& = 0;
2024-06-05 11:40:07     virtual auto AllowedSeedTypes() const noexcept -> const
2024-06-05 11:40:07         UnallocatedMap<opentxs::crypto::SeedStyle, std::string_view>& = 0;
2024-06-05 11:40:07     virtual auto Bip32Root(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const PasswordPrompt& reason) const -> UnallocatedCString = 0;
2024-06-05 11:40:07     virtual auto DefaultSeed() const
2024-06-05 11:40:07         -> std::pair<opentxs::crypto::SeedID, std::size_t> = 0;
2024-06-05 11:40:07     virtual auto GetHDKey(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const opentxs::crypto::EcdsaCurve& curve,
2024-06-05 11:40:07         const UnallocatedVector<opentxs::crypto::Bip32Index>& path,
2024-06-05 11:40:07         const PasswordPrompt& reason) const
2024-06-05 11:40:07         -> opentxs::crypto::asymmetric::key::HD = 0;
2024-06-05 11:40:07     virtual auto GetHDKey(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const opentxs::crypto::EcdsaCurve& curve,
2024-06-05 11:40:07         const UnallocatedVector<opentxs::crypto::Bip32Index>& path,
2024-06-05 11:40:07         const opentxs::crypto::asymmetric::Role,
2024-06-05 11:40:07         const PasswordPrompt& reason) const
2024-06-05 11:40:07         -> opentxs::crypto::asymmetric::key::HD = 0;
2024-06-05 11:40:07     virtual auto GetHDKey(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const opentxs::crypto::EcdsaCurve& curve,
2024-06-05 11:40:07         const UnallocatedVector<opentxs::crypto::Bip32Index>& path,
2024-06-05 11:40:07         const VersionNumber version,
2024-06-05 11:40:07         const PasswordPrompt& reason) const
2024-06-05 11:40:07         -> opentxs::crypto::asymmetric::key::HD = 0;
2024-06-05 11:40:07     virtual auto GetHDKey(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const opentxs::crypto::EcdsaCurve& curve,
2024-06-05 11:40:07         const UnallocatedVector<opentxs::crypto::Bip32Index>& path,
2024-06-05 11:40:07         const opentxs::crypto::asymmetric::Role,
2024-06-05 11:40:07         const VersionNumber version,
2024-06-05 11:40:07         const PasswordPrompt& reason) const
2024-06-05 11:40:07         -> opentxs::crypto::asymmetric::key::HD = 0;
2024-06-05 11:40:07     virtual auto GetPaymentCode(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const opentxs::crypto::Bip32Index nym,
2024-06-05 11:40:07         const std::uint8_t version,
2024-06-05 11:40:07         const PasswordPrompt& reason,
2024-06-05 11:40:07         alloc::Default alloc = {}) const
2024-06-05 11:40:07         -> opentxs::crypto::asymmetric::key::Secp256k1 = 0;
2024-06-05 11:40:07     virtual auto GetStorageKey(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const PasswordPrompt& reason) const
2024-06-05 11:40:07         -> opentxs::crypto::symmetric::Key = 0;
2024-06-05 11:40:07     virtual auto GetSeed(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         opentxs::crypto::Bip32Index& index,
2024-06-05 11:40:07         const PasswordPrompt& reason) const -> Secret = 0;
2024-06-05 11:40:07     virtual auto GetSeed(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& id,
2024-06-05 11:40:07         const PasswordPrompt& reason) const noexcept
2024-06-05 11:40:07         -> opentxs::crypto::Seed = 0;
2024-06-05 11:40:07     virtual auto ImportRaw(
2024-06-05 11:40:07         const Secret& entropy,
2024-06-05 11:40:07         const PasswordPrompt& reason,
2024-06-05 11:40:07         std::string_view comment = {},
2024-06-05 11:40:07         Time created = {}) const -> opentxs::crypto::SeedID = 0;
2024-06-05 11:40:07     virtual auto ImportSeed(
2024-06-05 11:40:07         const Secret& words,
2024-06-05 11:40:07         const Secret& passphrase,
2024-06-05 11:40:07         const opentxs::crypto::SeedStyle type,
2024-06-05 11:40:07         const opentxs::crypto::Language lang,
2024-06-05 11:40:07         const PasswordPrompt& reason,
2024-06-05 11:40:07         std::string_view comment = {},
2024-06-05 11:40:07         Time created = {}) const -> opentxs::crypto::SeedID = 0;
2024-06-05 11:40:07     OPENTXS_NO_EXPORT virtual auto Internal() const noexcept
2024-06-05 11:40:07         -> const internal::Seed& = 0;
2024-06-05 11:40:07     virtual auto LongestWord(
2024-06-05 11:40:07         const opentxs::crypto::SeedStyle type,
2024-06-05 11:40:07         const opentxs::crypto::Language lang) const noexcept -> std::size_t = 0;
2024-06-05 11:40:07     virtual auto NewSeed(
2024-06-05 11:40:07         const opentxs::crypto::SeedStyle type,
2024-06-05 11:40:07         const opentxs::crypto::Language lang,
2024-06-05 11:40:07         const opentxs::crypto::SeedStrength strength,
2024-06-05 11:40:07         const PasswordPrompt& reason,
2024-06-05 11:40:07         const std::string_view comment = {}) const
2024-06-05 11:40:07         -> opentxs::crypto::SeedID = 0;
2024-06-05 11:40:07     virtual auto Passphrase(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const PasswordPrompt& reason) const -> UnallocatedCString = 0;
2024-06-05 11:40:07     virtual auto SeedDescription(const opentxs::crypto::SeedID& seedID)
2024-06-05 11:40:07         const noexcept -> UnallocatedCString = 0;
2024-06-05 11:40:07     virtual auto SetDefault(const opentxs::crypto::SeedID& id) const noexcept
2024-06-05 11:40:07         -> bool = 0;
2024-06-05 11:40:07     virtual auto SetSeedComment(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& id,
2024-06-05 11:40:07         const std::string_view comment) const noexcept -> bool = 0;
2024-06-05 11:40:07     virtual auto ValidateWord(
2024-06-05 11:40:07         const opentxs::crypto::SeedStyle type,
2024-06-05 11:40:07         const opentxs::crypto::Language lang,
2024-06-05 11:40:07         const std::string_view word) const noexcept
2024-06-05 11:40:07         -> UnallocatedVector<UnallocatedCString> = 0;
2024-06-05 11:40:07     virtual auto WordCount(
2024-06-05 11:40:07         const opentxs::crypto::SeedStyle type,
2024-06-05 11:40:07         const opentxs::crypto::SeedStrength strength) const noexcept
2024-06-05 11:40:07         -> std::size_t = 0;
2024-06-05 11:40:07     virtual auto Words(
2024-06-05 11:40:07         const opentxs::crypto::SeedID& seedID,
2024-06-05 11:40:07         const PasswordPrompt& reason) const -> UnallocatedCString = 0;
2024-06-05 11:40:07 
2024-06-05 11:40:07     OPENTXS_NO_EXPORT virtual auto Internal() noexcept -> internal::Seed& = 0;
2024-06-05 11:40:07 
2024-06-05 11:40:07     Seed(const Seed&) = delete;
2024-06-05 11:40:07     Seed(Seed&&) = delete;
2024-06-05 11:40:07     auto operator=(const Seed&) -> Seed& = delete;
2024-06-05 11:40:07     auto operator=(Seed&&) -> Seed& = delete;
2024-06-05 11:40:07 
2024-06-05 11:40:07     OPENTXS_NO_EXPORT virtual ~Seed() = default;
2024-06-05 11:40:07 
2024-06-05 11:40:07 protected:
2024-06-05 11:40:07     Seed() = default;
2024-06-05 11:40:07 };
2024-06-05 11:40:07 }  // namespace opentxs::api::crypto
2024-06-05 11:40:07 Traceback (most recent call last):
2024-06-05 11:40:07   File "/app/opendevin/controller/agent_controller.py", line 130, in _start_step_loop
2024-06-05 11:40:07     await self._step()
2024-06-05 11:40:07   File "/app/opendevin/controller/agent_controller.py", line 276, in _step
2024-06-05 11:40:07     raise MaxCharsExceedError(self.state.num_of_chars, self.max_chars)
2024-06-05 11:40:07 opendevin.core.exceptions.MaxCharsExceedError: Number of characters 5018083 exceeds MAX_CHARS limit: 5000000
2024-06-05 11:40:07 16:40:07 - opendevin:ERROR: agent_controller.py:136 - Error while running the agent: Number of characters 5018083 exceeds MAX_CHARS limit: 5000000
2024-06-05 11:40:07 16:40:07 - opendevin:ERROR: agent_controller.py:137 - Traceback (most recent call last):
2024-06-05 11:40:07   File "/app/opendevin/controller/agent_controller.py", line 130, in _start_step_loop
2024-06-05 11:40:07     await self._step()
2024-06-05 11:40:07   File "/app/opendevin/controller/agent_controller.py", line 276, in _step
2024-06-05 11:40:07     raise MaxCharsExceedError(self.state.num_of_chars, self.max_chars)
2024-06-05 11:40:07 opendevin.core.exceptions.MaxCharsExceedError: Number of characters 5018083 exceeds MAX_CHARS limit: 5000000
2024-06-05 11:40:07 
2024-06-05 11:40:07 16:40:07 - opendevin:INFO: agent_controller.py:183 - [Agent Controller 960fc3b2-a129-4fd0-8769-b03eae593f28] Setting agent(CodeActAgent) state from AgentState.RUNNING to AgentState.ERROR
2024-06-05 11:40:07 INFO:     192.168.65.1:47537 - "GET /api/list-files?path=/ HTTP/1.1" 200 OK
2024-06-05 11:40:07 INFO:     192.168.65.1:47541 - "GET /api/list-files?path=/opentxs/include/ HTTP/1.1" 200 OK
2024-06-05 11:40:07 INFO:     192.168.65.1:47542 - "GET /api/list-files?path=/opentxs/ HTTP/1.1" 200 OK
2024-06-05 11:40:07 INFO:     192.168.65.1:47538 - "GET /api/list-files?path=/opentxs/include/opentxs/api/ HTTP/1.1" 200 OK
2024-06-05 11:40:07 INFO:     192.168.65.1:47539 - "GET /api/list-files?path=/opentxs/include/opentxs/api/session/ HTTP/1.1" 200 OK
2024-06-05 11:40:07 INFO:     192.168.65.1:47540 - "GET /api/list-files?path=/opentxs/include/opentxs/ HTTP/1.1" 200 OK
enyst commented 1 month ago

I'm not sure off-hand if there's some other problem here, but if it got to 5,000,000 characters and you want it to continue, you can configure this value in config.toml, for example:

max_chars=10000000

or as few or as many as you like. Do you think it's too few by default?

INTIMSOCIAL commented 1 month ago

I'm not sure off-hand if there's some other problem here, but if it got to 5,000,000 characters and you want it to continue, you can configure this value in config.toml, for example:

max_chars=10000000

or as few or as many as you like. Do you think it's too few by default?

Is there a way to modify that in docker? Im very new to docker.

FellowTraveler commented 1 month ago

Well if it's going through the headers 1-by-1 and diagramming them, and since the header itself appears in the log I posted, I guess my question becomes:

Do you really think that header above in the log is 5,000,000 chars long?

EDIT: This might explain how I spent $20 last night on the API diagramming headers...

SmartManoj commented 1 month ago

Is there a way to modify that in docker?

Pass -e MAX_CHARS=10000000

enyst commented 1 month ago

Well if it's going through the headers 1-by-1 and diagramming them, and since the header itself appears in the log I posted, I guess my question becomes:

Do you really think that header above in the log is 5,000,000 chars long?

EDIT: This might explain how I spent $20 last night on the API diagramming headers...

max_chars keeps count of all calls to the API during a session, not just one message. So if this is step 42, it includes a count of characters in the other steps too and their history. In other words, it counts your successive contexts sent to the openai API. Also, at least in some cases, I think it also includes stuff done before, e.g. when you are asked if you want to resume the same session and successfully do so (it's using the same session and continues to count), but I should say it's not clear to me this last one was the case here or not.

The intention of this max_chars variable check is precisely to allow users to control cost in some way. It might not be a perfect way... it's one way.

We actually have a newer feature more on point, I think, max_budget_per_task. New enough to me too that I haven't actually tried it yet. πŸ˜… Its meaning is exactly what you'd think: the maximum budget (in USD) allowed per task, beyond which the agent will stop.

li-boxuan commented 1 month ago

Yeah budget is usually more useful, but it's only accurate (or maybe applicable) to several models, e.g. OpenAI models. max_chars gives you more control but that doesn't directly translate to dollar values.

BishopCrypto commented 4 weeks ago

It seems like crashing isn't the best response to this 'error'.

FellowTraveler commented 4 weeks ago

Should create a Budget class which is able to set budget by token, as well as by time, as well as by number of tries. (If an agent runs out of time, or tries 3 times, or runs out of tokens...)