Skip to content

fix(api): normalize Letta URLs and avoid self-hosted conversations redirect#31

Merged
cpfiffer merged 1 commit intomainfrom
fix/selfhosted-conversations-trailing-slash
Mar 17, 2026
Merged

fix(api): normalize Letta URLs and avoid self-hosted conversations redirect#31
cpfiffer merged 1 commit intomainfrom
fix/selfhosted-conversations-trailing-slash

Conversation

@cpfiffer
Copy link
Collaborator

Summary

  • Add a shared URL builder (scripts/letta_api_url.ts) to centralize LETTA_BASE_URL normalization and API URL construction.
  • Fix createConversation to call /v1/conversations/ (trailing slash) with agent_id query parameters, avoiding proxy redirect issues that can downgrade to HTTP.
  • Migrate script API calls to buildLettaApiUrl(...) and remove duplicated inline base URL construction.
  • Add regression tests for URL building and createConversation endpoint shape.

Root cause

createConversation previously posted to /v1/conversations?agent_id=... (no trailing slash). Some self-hosted reverse-proxy setups redirect this to /v1/conversations/?... and emit an incorrect Location with http://, causing Node fetch redirect-follow to fail with fetch failed.

Test plan

  • npm test
  • Added scripts/letta_api_url.test.ts (base normalization, query construction, trailing slash preservation)
  • Added scripts/conversation_utils.test.ts (createConversation uses /conversations/ endpoint)

👾 Generated with Letta Code

…direct

Use a shared URL builder across scripts and update createConversation to call /v1/conversations/ with query params to avoid HTTPS->HTTP redirect failures behind reverse proxies. This also deduplicates LETTA_API_BASE handling and adds regression tests for trailing-slash behavior.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
@cpfiffer cpfiffer merged commit 04c3423 into main Mar 17, 2026
1 check passed
@cpfiffer cpfiffer deleted the fix/selfhosted-conversations-trailing-slash branch March 17, 2026 17:21
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