Files
cleveractors-core/features/llm_tools_coverage.feature
CoreRasurae 227e2feece
CI / build (pull_request) Successful in 45s
CI / quality (pull_request) Successful in 58s
CI / lint (pull_request) Successful in 1m15s
CI / typecheck (pull_request) Successful in 1m15s
CI / security (pull_request) Successful in 1m15s
CI / integration_tests (pull_request) Successful in 1m24s
CI / unit_tests (pull_request) Successful in 3m25s
CI / coverage (pull_request) Successful in 3m10s
CI / status-check (pull_request) Successful in 6s
CI / lint (push) Successful in 42s
CI / quality (push) Successful in 48s
CI / typecheck (push) Successful in 51s
CI / security (push) Successful in 49s
CI / build (push) Successful in 47s
CI / integration_tests (push) Successful in 1m10s
CI / unit_tests (push) Successful in 3m9s
CI / coverage (push) Successful in 3m7s
CI / status-check (push) Successful in 3s
feat(agents): implement multi-turn tool-call loop and sandbox improvements
Implements the complete LLM agent tool-calling pipeline — the tool-calling
path was broken in multiple ways: tools from agent config were not passed
to the LLM, tool execution was single-pass (the model could not see tool
results or make follow-up calls), tool errors were discarded, and shell/
python_exec tools were never registered.

Key changes:

- Multi-turn tool-call loop: passes tools to the LLM via ainvoke(tools=...)
  and re-invokes after each batch of ToolResults, with a configurable
  round limit (tool_max_rounds config / TOOL_MAX_ROUNDS env var, default 20).

- Tool schema module (llm_tools.py): normalize_tool_entry() converts
  string tool names and config dicts to OpenAI function-calling format
  with full parameter schemas and LLM-facing guidance (max_chars for
  file_read, sandbox builtins for python_exec, etc.).

- file_read enhancements: directory listing with file sizes and type
  indicators, max_chars truncation to prevent context overflow, shell
  command detection with redirect to shell tool, file-not-found
  recovery hints with parent directory listing.

- python_exec sandbox: stdout capture so print() produces visible
  output, NameError guidance directing LLM to file_read/file_write
  instead of using open().

- shell/python_exec tool registration in builtin_tools when
  allow_shell / exec_python is enabled.

- create_subprocess_shell for shell commands (was create_subprocess_exec,
  which blocks pipes/redirections/chains).

- Tool error propagation: ExecutionError/ConfigurationError details
  included in ToolMessages for LLM self-correction.

- Stuck-model recovery: injects synthesizing prompt when model
  exhausts tool rounds without producing content.

- LLM provider error details preserved in ExecutionError messages
  instead of generic "LLM processing failed".

- Empty message filtering in _prepare_conversation_history() prevents
  whitespace-only messages from polluting downstream conversation
  history in multi-agent pipelines.

Closes #59
2026-06-23 12:39:20 +01:00

34 lines
1.6 KiB
Gherkin

Feature: LLM Tools Coverage
As a developer
I want to cover remaining uncovered lines in llm_tools.py
So that coverage reaches the target
Scenario: normalize_tool_entry returns OpenAI-formatted dict as-is
Given an llm_tools coverage test environment
When I call normalize_tool_entry with OpenAI-formatted dict
Then the result should be the same dict unchanged
Scenario: normalize_tool_entry rejects dict missing valid name
Given an llm_tools coverage test environment
When I call normalize_tool_entry with dict missing name
Then a ConfigurationError mentioning non-empty string 'name' is raised
Scenario: normalize_tool_entry rejects dict with empty name
Given an llm_tools coverage test environment
When I call normalize_tool_entry with dict having empty name
Then a ConfigurationError mentioning non-empty string 'name' is raised
Scenario: normalize_tool_entry converts string tool name to OpenAI format
Given an llm_tools coverage test environment
When I call normalize_tool_entry with string "echo"
Then the result should be OpenAI dict with name echo
Scenario: normalize_tool_entry rejects empty string
Given an llm_tools coverage test environment
When I call normalize_tool_entry with empty string
Then a ConfigurationError mentioning non-empty string is raised
Scenario: normalize_tool_entry rejects non-str non-dict type
Given an llm_tools coverage test environment
When I call normalize_tool_entry with integer 42
Then a ConfigurationError mentioning Invalid tool config entry is raised