8 Commits

Author SHA1 Message Date
CoreRasurae 4fe14c5b77 feat(agents): add offset-based pagination to file_read
CI / lint (pull_request) Successful in 1m40s
CI / quality (pull_request) Successful in 2m7s
CI / typecheck (pull_request) Successful in 3m23s
CI / build (pull_request) Successful in 1m6s
CI / security (pull_request) Successful in 4m51s
CI / integration_tests (pull_request) Successful in 3m14s
CI / unit_tests (pull_request) Successful in 5m24s
CI / coverage (pull_request) Successful in 6m51s
CI / status-check (pull_request) Successful in 7s
CI / benchmark (pull_request) Failing after 17m20s
CI / lint (push) Successful in 59s
CI / typecheck (push) Successful in 2m21s
CI / security (push) Successful in 1m16s
CI / quality (push) Successful in 51s
CI / build (push) Successful in 1m29s
CI / integration_tests (push) Successful in 3m28s
CI / unit_tests (push) Successful in 4m37s
CI / coverage (push) Successful in 4m58s
CI / status-check (push) Successful in 7s
CI / benchmark (push) Failing after 18m9s
`file_read` always read from position 0; `max_chars` (ADR-2030 D-3) only
bounded where the returned content stopped, so once a large file was
truncated there was no way to retrieve the next chunk short of falling
back to the `shell` tool (`tail -c +N`, `sed -n`, `dd skip=...`) — the
same class of awkward, error-prone detour ADR-2030 D-4 already eliminated
for file paths mistaken for shell commands.

Adds an optional `offset` character-position argument (default 0,
byte-for-byte identical output when omitted) to both the tool schema
(`llm_tools._BUILTIN_TOOL_SCHEMAS["file_read"]`) and the implementation
(`ToolAgent._file_read_tool`). Combined with `max_chars` it returns the
window `[offset, offset + max_chars)`, and the `[FILE_READ_SUCCESS]`
header now signals continuation: `MORE_CONTENT_AT_OFFSET: N` when more
content remains (N is the exact next offset, so callers never compute
`offset + max_chars` themselves), or `NO_MORE_CONTENT_AT_OFFSET: N` when
the requested offset is at or beyond end-of-file — a success response
with empty content, not an error, since that is the expected terminal
state of a correctly-paginating caller. Negative or non-integer offsets
raise `ExecutionError`, mirroring the existing `max_chars` validation
pattern.

See docs/adr/ADR-2033-file-read-offset-pagination.md for the full set of
design decisions, including why directory-listing pagination and
byte-level seeking are deferred to a future issue.

ISSUES CLOSED: #83
2026-07-31 08:53:31 +00:00
CoreRasurae 55734cd512 feat(agents): add LLM agent retry mechanisms with exponential backoff
- Documents the retry feature implementation (issue #69, ADR-2032)

Introduce configurable retry mechanisms (ADR-2032) for all LLM agent
communications (main agent and pruning agent) with exponential backoff.

- New config fields: max_retries (default 7), max_retry_time (default 60s)
  -1 sentinel disables the corresponding guard (infinite retries/time)
- Exponential backoff: initial 0.5s, doubled each retry
- Termination: whichever comes first (max_retries or max_retry_time),
  with -1 disabling the respective check
- Counter and accumulated wait time reset on success
- Timeout ExecutionError includes URL, actor graph name, and retry stats
- Uniform scope: applies to both main agent and pruning agent
- Timeout raises ExecutionError(kind="timeout") with URL, actor graph
  name, retry count, and accumulated wait time in the message (D-7)
- Same client/connection reused across retries, no re-establishment (D-6)
- Uniform scope: applies to both main agent and pruning agent (D-5)
- Graph name threaded through state metadata and ContextVar for error
  reporting
- BDD tests (7 scenarios) for retry behaviour including -1 sentinel cases
- Reject max_retries/max_retry_time values < -1 with ConfigurationError
- Reset current_graph_name ContextVar after node execution
- Wrap no-tools astream() with per-chunk granular retry via call_with_retry
- Update ADR D-7 with symmetrical disabled-guard example
- Update CHANGELOG to reflect full feature scope

ISSUES CLOSED: #69
2026-07-03 16:00:11 +01:00
CoreRasurae 964e87cc0f feat(tool-loop): add token-budget awareness and tool output pruning
CI / lint (pull_request) Successful in 1m31s
CI / typecheck (pull_request) Successful in 50s
CI / security (pull_request) Successful in 50s
CI / quality (pull_request) Successful in 33s
CI / unit_tests (pull_request) Successful in 3m5s
CI / integration_tests (pull_request) Successful in 1m7s
CI / build (pull_request) Successful in 34s
CI / coverage (pull_request) Successful in 3m7s
CI / status-check (pull_request) Successful in 3s
CI / lint (push) Successful in 33s
CI / typecheck (push) Successful in 50s
CI / security (push) Successful in 50s
CI / quality (push) Successful in 33s
CI / integration_tests (push) Successful in 1m12s
CI / build (push) Successful in 33s
CI / unit_tests (push) Successful in 3m5s
CI / coverage (push) Successful in 3m6s
CI / status-check (push) Successful in 6s
Implement token-budget awareness (§4.4.7) and tool output pruning
(§4.4.8-9) for the multi-turn tool-call loop to prevent context-window
exhaustion.

Token budget: tracks estimated token count before each ainvoke(), emits
warning at 75% budget, injects synthesis prompt at exhaustion with one
final tool-call round. Estimation via chat_model.get_num_tokens() with
len(content)//4 heuristic fallback. Config key: token_budget_percent.

Tool output pruning: implicit LLM extraction pass scoped to file_read
calls. Schema augmentation injects output_prune (bool) and
output_prune_context (string) meta-arguments. Pruning model responds
with [PRUNE_INFO_START/END] and [PRUNE_OUTPUT_START/END] markers.
Config keys: allow_tool_output_pruning, pruning_model.

- Capture output_prune value in budget synthesis flow with proper guard
- Fix ADR D-4: synthesis prompt is HumanMessage not SystemMessage
- Fix Robot tests: replace /dev/null with temp file path

ADR-2031 documents all specification extensions. 21 new BDD scenarios,
5 Robot integration tests, 16 ASV benchmarks.

ISSUES CLOSED: #61
2026-06-26 18:21:14 +01:00
CoreRasurae 227e2feece feat(agents): implement multi-turn tool-call loop and sandbox improvements
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
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
CoreRasurae 9dc3f7910b docs(registry): add MkDocs API documentation and usage examples for Package Registry Client
CI / lint (push) Successful in 1m7s
CI / typecheck (push) Successful in 1m8s
CI / security (push) Successful in 1m7s
CI / quality (push) Successful in 41s
CI / integration_tests (push) Successful in 1m13s
CI / build (push) Successful in 1m22s
CI / unit_tests (push) Successful in 3m13s
CI / coverage (push) Successful in 3m9s
CI / status-check (push) Successful in 3s
Created comprehensive MkDocs-formatted API documentation under docs/registry/
covering all public API surfaces from the registry subsystem with real-life
constructive examples:

- index.md: Architecture overview, module relationships, quickstart
- types.md: PackageType, PackageId, PackageReference, PackageContent
- client.md: RegistryClient with all 4 endpoints, auth modes, async patterns
- canonical.md: Canonicalizer pipeline — NFC, RFC-8785, SHA-1, lifecycle stripping
- resolver.md: ReferenceResolver — 3 reference schemes, version alias resolution
- exceptions.md: RegistryError hierarchy — all 9 typed exceptions with HTTP mapping
- cache.md: RegistryCache — LRU eviction, TTL, SHA-1 tamper detection, singleflight
- integration.md: 4 end-to-end workflows (ordering pipeline, email categorization,
  CI/CD verification, multi-tenant provisioning)

Updated mkdocs.yml nav tree with docs/registry/ entries.

Refs: #51
2026-06-17 14:09:28 +00:00
CoreRasurae e8bd348c77 feat(registry): implement RegistryError hierarchy with typed exceptions
CI / lint (pull_request) Successful in 41s
CI / typecheck (pull_request) Successful in 56s
CI / security (pull_request) Successful in 51s
CI / quality (pull_request) Successful in 53s
CI / integration_tests (pull_request) Successful in 1m10s
CI / build (pull_request) Successful in 43s
CI / unit_tests (pull_request) Successful in 3m30s
CI / coverage (pull_request) Successful in 3m22s
CI / status-check (pull_request) Successful in 4s
CI / quality (push) Successful in 45s
CI / security (push) Successful in 48s
CI / lint (push) Successful in 49s
CI / typecheck (push) Successful in 50s
CI / build (push) Successful in 49s
CI / integration_tests (push) Successful in 1m9s
CI / unit_tests (push) Successful in 3m13s
CI / coverage (push) Successful in 3m7s
CI / status-check (push) Successful in 3s
Add RegistryError base with message, details, and original_reference fields.
Implement all 9 typed exception types per Package Registry Standard §13.2:
PackageNotFoundError, InvalidPackageIdError, InvalidPackageReferenceError,
VersionNotFoundError, ValidationError, AuthenticationRequiredError,
AccessDeniedError, ConflictError, and RegistryNetworkError.

RegistryNetworkError carries status_code and url for transport failures.
__str__ includes original_reference when available.
exception_for_status() maps HTTP codes to typed exceptions.
_ERROR_TYPE_MAP enables error-type parsing from JSON error bodies.

23 Behave BDD scenarios in features/registry_exceptions.feature.
12 Robot Framework integration tests in robot/exceptions.robot.
Existing registry_http_client tests updated for InternalServerError removal.

ISSUES CLOSED: #29
2026-06-11 20:44:54 +01:00
CoreRasurae f787b52c7e docs: Setup project documentation 2026-05-26 22:13:33 +01:00
CoreRasurae 55ce2acfdf chore: Base repo structure commit 2026-05-26 21:45:54 +01:00