Skip to content

Cognito Agent Phase 1: Agent Loop + Tool Execution#3

Merged
Axlfc merged 1 commit into
masterfrom
feat/cognito-agent-loop-fase1-17852941190475397888
Jul 9, 2026
Merged

Cognito Agent Phase 1: Agent Loop + Tool Execution#3
Axlfc merged 1 commit into
masterfrom
feat/cognito-agent-loop-fase1-17852941190475397888

Conversation

@Axlfc

@Axlfc Axlfc commented Jul 9, 2026

Copy link
Copy Markdown
Owner

This PR implements Phase 1 of the Cognito Agent. It adds a new Agent Loop capable of executing tools with strict security guarantees.

Key changes:

  • New endpoint: POST /api/agent/loop (SSE).
  • Agent Loop: Orchestrates multi-turn turns between the user and the model, executing tool calls requested by the model.
  • Tools:
    • read: Reads files within the workspace.
    • write: Writes/overwrites files (requires trust, enforces protected files).
    • edit: Search-and-replace editing (requires trust, enforces protected files).
    • bash: Executes shell commands (requires trust, rejects sudo, implements 30s-120s timeout).
  • Security:
    • ProjectTrustStore: Persists repository-level trust status in ~/.cognito/trust.json.
    • PROTECTED_FILES: Prevents modification of critical files like auth.js.
    • Path Traversal Protection: All file tools are restricted to the provided cwd.
  • Backend Enhancements:
    • Ollama: Uses /api/chat for native tool calling support.
    • OpenAI: Compatible with standard tool calling schemas.
    • Probing: Automatically detects tool support and caches results in-memory.
    • Failover: Correctly skips backends without tool support.
  • Uncertainty: Token-level uncertainty is calculated and streamed in SSE events.
  • Tests: Added comprehensive unit tests for all new core components.

PR created automatically by Jules for task 17852941190475397888 started by @Axlfc

- Added SSE endpoint `POST /api/agent/loop` for agent execution.
- Implemented core agent loop with tool support.
- Added four initial tools: `read`, `write`, `edit`, and `bash`.
- Implemented security measures: `ProjectTrustStore`, `PROTECTED_FILES`, and `sudo` rejection.
- Enhanced `BackendClient` and `BackendRouter` with tool-calling support and failover.
- Refactored uncertainty calculation to `app/core/uncertainty.py`.
- Added unit tests for tools, trust store, and agent loop.
- Updated documentation and added `AGENTS.md`.

Co-authored-by: Axlfc <14998495+Axlfc@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@Axlfc Axlfc merged commit 7ff61ad into master Jul 9, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

1 participant