Commit Graph

94 Commits

Author SHA1 Message Date
Ariel Frischer 32fcf914ed
Set Default Max Token Limit with Provider/Model Dictionary and Limit Tokens for Anthropic Claude React Agent (#45)
* feat(agent_utils.py): add get_model_token_limit function to retrieve token limits for models based on provider and model name
feat(models_tokens.py): create models_tokens module to store token limits for various models and providers
test(agent_utils.py): implement unit tests for get_model_token_limit and create_agent functions to ensure correct behavior and error handling

* test: Add unit tests for token limiting and agent creation functionality

* fix: Correct indentation and add missing test function for error handling

* fix: Update test assertion to use messages_modifier instead of state_modifier

* feat(agent_utils.py): add limit_tokens function to manage message token limits and preserve system message
fix(agent_utils.py): update get_model_token_limit to handle exceptions and return None on error
fix(ciayn_agent.py): set default max_tokens to DEFAULT_TOKEN_LIMIT in CiaynAgent initialization
feat(models_tokens.py): define DEFAULT_TOKEN_LIMIT for consistent token limit management across agents
style(agent_utils.py): improve code formatting and consistency in function definitions and comments
style(agent_utils.py): refactor imports for better organization and readability
fix(test_agent_utils.py): correct test assertion to use state_modifier instead of messages_modifier for create_agent function

* refactor(agent_utils.py): improve docstring clarity and formatting for limit_tokens function to enhance readability
refactor(test_agent_utils.py): format test assertions for consistency and readability in agent creation tests

* feat: Update limit_tokens function to support Dict type for state parameter

* feat: Update limit_tokens to handle both list and dict input types

* refactor: Extract duplicate token trimming logic into helper function

* refactor: Rename and update message trimming functions for clarity

* refactor: Extract agent kwargs logic into a helper method for reuse

* refactor: Rename _build_agent_kwargs to build_agent_kwargs for clarity

* fix: Ensure state_modifier is passed correctly for agent creation

* test: Add tests for create_agent token limiting configuration

* refactor: Simplify CiaynAgent instantiation to only use max_tokens parameter

* refactor: Remove is_react_agent parameter from build_agent_kwargs function

* test: Fix test assertions for state_modifier in agent creation tests

* fix: Update agent creation to handle checkpointer and simplify tests

* test: Remove unnecessary assertions from agent creation test

* feat: Implement token limiting configuration for create_agent function

* refactor: Remove unused model info and token limit retrieval code

* test: Fix assertion errors in agent creation tests and update state_modifier handling

* test: Remove commented-out code and clarify assertions in tests

* test: Fix assertion in test_create_agent_anthropic_token_limiting_disabled

* feat(main.py): add --limit-tokens argument to control token limiting in agent state
fix(main.py): include limit_tokens in configuration to ensure proper state management

* test: Refactor agent creation tests for improved readability and consistency

* test: Modify error handling in create_agent test to use side_effect on get_model_token_limit

* test: Improve error handling in create_agent test to verify fallback behavior

* test: Trigger exception on get_model_token_limit in error handling test

* refactor(agent_utils.py): remove unused config parameter from create_agent function to simplify the function signature
fix(agent_utils.py): ensure config is always retrieved from _global_memory with a default value to prevent potential errors
test(tests/test_agent_utils.py): remove outdated test for create_agent error handling to clean up the test suite

* feat: Add debug print for agent_kwargs in create_agent function

* refactor: Replace lambda with inner function for state_modifier in agent_utils

* refactor: Simplify limit_tokens function to return only message sequences

* feat: Add debug print statements to show token trimming details in trim_messages

* PAIN

* feat(main.py): add debug print statement for args.chat to assist in troubleshooting chat mode
feat(agent_utils.py): implement estimate_messages_tokens function to calculate total tokens in messages
refactor(agent_utils.py): replace token counting logic in trim_messages_with_removal with estimate_messages_tokens for clarity
refactor(agent_utils.py): modify state_modifier to accept model and max_tokens parameters for better flexibility
refactor(agent_utils.py): update build_agent_kwargs to pass model to state_modifier for improved functionality

* feat: Add .direnvrc to manage Python virtual environment activation

* refactor: Update state_modifier to handle first message token count and trim messages

* chore: remove unused .direnvrc file to clean up project structure
feat: add .envrc to .gitignore to prevent environment configuration file from being tracked
fix: update help text for --disable-limit-tokens argument for clarity
refactor: clean up imports in agent_utils.py for better readability
refactor: remove unused functions and comments in agent_utils.py to streamline code
test: add unit tests for state_modifier function to ensure correct message trimming behavior

* refactor: Remove commented-out code in create_agent function

* feat: Add is_anthropic_claude method to check provider and model name

* fix: Correct search/replace block to match existing lines in agent_utils.py

* fix(main.py): update help text for --disable-limit-tokens argument to clarify it applies to react agents
refactor(agent_utils.py): streamline token limit retrieval and improve readability by removing redundant checks and restructuring code
refactor(agent_utils.py): modify build_agent_kwargs to use is_anthropic_claude for clarity and maintainability

* test: Update tests to pass config argument to get_model_token_limit()

* refactor(agent_utils.py): remove unnecessary print statements and improve function signatures for clarity
refactor(agent_utils.py): consolidate provider and model_name retrieval into config parameter for better maintainability

* test: Remove redundant token limiting tests from agent creation logic

* test: Refactor test_state_modifier to use mock_messages fixture

* test(tests): update test description for clarity on state_modifier behavior and use mock_messages for assertions to ensure consistency

* refactor(agent_utils.py): simplify token limit retrieval by removing unnecessary variable initialization and defaulting to None in get method

* chore(main.py): remove debug print statement for args.chat to clean up output
2025-01-20 14:41:29 -05:00
AI Christianson 0c39166172 Increase recusion limit; Handle 429 better; Improve prompts. 2025-01-09 15:52:51 -05:00
AI Christianson d01d2a4865 Integrate project info into chat prompt. 2025-01-09 15:01:39 -05:00
AI Christianson b631a4bf57 Get project info programmatically to save tokens. 2025-01-09 14:43:42 -05:00
AI Christianson 4b24dbe960 Improve work log handling. 2025-01-09 13:42:26 -05:00
AI Christianson ba82f41fa0 Only include work_log key if needed, to save tokens. 2025-01-09 12:57:58 -05:00
AI Christianson 80d2d2fa60 Better handle 429 errors on openrouter. 2025-01-09 11:42:13 -05:00
AI Christianson a8084f15f9 Fix typo 2024-12-29 14:52:39 -05:00
AI Christianson ace34633de Adjustments to get smaller agent models working better. 2024-12-28 18:19:42 -05:00
AI Christianson 684b076dbf Adjustments to get smaller agent models working better. 2024-12-28 17:31:41 -05:00
AI Christianson 19e203be7e Use create_react_agent for claude. 2024-12-28 17:19:12 -05:00
AI Christianson cf485bd96c Merge llm-fn-call: resolve changelog conflicts 2024-12-28 16:56:34 -05:00
Jose M Leon 8b3f4d736c
FEAT fix command line args and env var dependencies on anthropic (#21)
* FIX provider cmdline args

* FIX Issue 18

* FIX ensure research-only requires a model
2024-12-28 16:53:57 -05:00
AI Christianson 406d1a5358 ciayn 2024-12-28 16:44:06 -05:00
AI Christianson 13b953bf7f extract creat agent method 2024-12-28 15:39:33 -05:00
AI Christianson 2af7f8a623 ciayn 2024-12-28 15:18:58 -05:00
AI Christianson 10b58bb2db Simplify planning stage by executing tasks directly. Make research notes available to more agents/tools. 2024-12-27 17:03:47 -05:00
AI Christianson f2ce6a7ab0 Improve prompts and fix web research prompt integration. 2024-12-27 15:26:54 -05:00
AI Christianson 868835ece8 Fix logging on interrupt. 2024-12-26 17:28:39 -05:00
user 8018bce252 Fix variable reference. 2024-12-26 07:08:28 -05:00
Jose Leon 204f44cda0 FEAT add verbose logging 2024-12-26 00:45:57 +00:00
user 25b1dae8cb Clean up imports. 2024-12-24 08:33:10 -05:00
user 72f8c33e43 Fix bugs. 2024-12-24 08:31:08 -05:00
user c0fa79fe77 Improve web research prompts. 2024-12-24 06:54:56 -05:00
user 1ab7ce60ea Tavily integration 2024-12-23 17:20:24 -05:00
user f5482dce2a Added web research tool config. 2024-12-23 17:08:07 -05:00
user 481d80dc53 Add web research agent fn. 2024-12-23 16:36:40 -05:00
user f9fd6a4cde Add web research prompt section. 2024-12-23 16:21:28 -05:00
user 21611953d7 Clean up exception handling. 2024-12-23 14:54:28 -05:00
user 8ffcac867b Interruption UX. 2024-12-23 14:23:10 -05:00
user f7523e86d8 Improve agent interruption UX by allowing user to specify feedback or exit the program entirely. 2024-12-23 14:05:59 -05:00
user e5035569fa Include work log in task agent context. 2024-12-23 13:06:37 -05:00
user 9a53940dcd Track agent depth for all agents. 2024-12-23 12:05:39 -05:00
user 79360f761c Introduce dedicated RESEARCH_ONLY_PROMPT. 2024-12-22 15:00:39 -05:00
user f80545d693 Allow graceful interruption of agents. 2024-12-22 14:00:17 -05:00
user 59af95acf7 Enforce research recursion limit. 2024-12-22 09:54:05 -05:00
user 53adb4d6e6 Improve UX. 2024-12-22 08:45:12 -05:00
user c41fac82b7 Include known context in research prompt. 2024-12-21 20:20:00 -05:00
user 5053b36d8b Fix printing of agent output. 2024-12-21 15:35:05 -05:00
user ecb6796008 Extract run_planning_agent. 2024-12-21 14:10:55 -05:00
user f92c30b4e6 Allow individual tasks to be marked completed. 2024-12-21 13:50:40 -05:00
user 37e36967ee Introduce run_task_implementation_agent. 2024-12-21 13:13:50 -05:00
AI Christianson ae6052ed15 Introduce run_research_agent. 2024-12-21 12:19:43 -05:00
AI Christianson 1fc64c5151 Allow chat agent to spawn research agent. 2024-12-21 10:58:08 -05:00