Skip to content

Conversation

@mcavage
Copy link

@mcavage mcavage commented Dec 7, 2025

Replace two separate agent routes with a single wildcard route that can handle agent paths containing slashes. This allows agents to be organized in nested directories or namespaces.

The new routing logic:

  • Uses a wildcard parameter to capture the full agent path
  • Handles paths with or without leading slashes
  • Supports optional agent_name as the final path segment
  • Maintains backward compatibility with existing paths

🤖 Generated with Claude Code

Replace two separate agent routes with a single wildcard route that can
handle agent paths containing slashes. This allows agents to be organized
in nested directories or namespaces.

The new routing logic:
- Uses a wildcard parameter to capture the full agent path
- Handles paths with or without leading slashes
- Supports optional agent_name as the final path segment
- Maintains backward compatibility with existing paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@BobDickinson
Copy link
Contributor

FWIW, I'm building a TypeScript client to talk to the cagent API and I ran into this exact issue (agent id from API contained full path, and when using that exact ID in subsequent call paths the calls failed because the router wasn't processing the path segments properly). I applied this PR to a feature branch to test and it solved my problem.

@BobDickinson
Copy link
Contributor

BobDickinson commented Dec 13, 2025

Fix Errors

The PR has linter errors (which would also fail build if not caught there) because it's based on code from before the sessionManager refactoring (commit 9f152767). Here are the required fixes:

pkg/server/server.go

  1. Add strings import (line ~11):
import (
	// ... existing imports ...
	"strings"  // ADD THIS
	"time"
)
  1. Replace s.agentSources with s.sm.sources (3 occurrences):
    • Line ~225: s.agentSources[path]s.sm.sources[path]
    • Line ~230: s.agentSources[withSlash]s.sm.sources[withSlash]
    • Line ~235: s.agentSources[withoutSlash]s.sm.sources[withoutSlash]

pkg/server/server_test.go

  1. Update New() call (line ~101):
// Before:
srv, err := New(store, &runConfig, sources)

// After:
ctx := t.Context()  // ctx is already declared earlier in the function
srv, err := New(ctx, store, &runConfig, 0, sources)

These changes align the PR with the current codebase structure that uses sessionManager instead of direct agentSources field and will allow it to pass the CI checks.

I had to apply these fixes to my feature branch to test the PR.

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.

2 participants