这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@VAIBHAVSING
Copy link
Contributor

@VAIBHAVSING VAIBHAVSING commented Oct 1, 2025

This PR initializes session's Env map when resuming sessions and inherits daemon-level ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY into spawned Claude processes when not explicitly set.
Why: Enables running Claude against Anthropic-compatible endpoints such as AWS Bedrock by setting the env vars at the daemon level.
Changes:
Initialize config.Env in resumed session flow to avoid nil map panics\n- Inject ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from the daemon environment into session Env when missing
Closes #598


Important

Inherit ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from daemon environment into Claude sessions in manager.go, enabling Anthropic-compatible endpoints.

  • Behavior:
    • In LaunchSession and ContinueSession in manager.go, inherit ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from daemon environment if not set in session config.
    • Initialize config.Env map in ContinueSession to prevent nil map panics.
  • Purpose:
    • Allows running Claude against Anthropic-compatible endpoints by setting environment variables at the daemon level.
  • Misc:

This description was created by Ellipsis for 3881710. You can customize this summary. It will automatically update as commits are pushed.

@CLAassistant
Copy link

CLAassistant commented Oct 1, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 3881710 in 1 minute and 12 seconds. Click for details.
  • Reviewed 70 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. hld/session/manager.go:366
  • Draft comment:
    Good use of initializing claudeConfig.Env and then conditionally inheriting ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from the daemon. This properly avoids nil map panics and respects explicit overrides.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. hld/session/manager.go:1722
  • Draft comment:
    Similarly, in ContinueSession the config.Env is initialized and daemon-level ANTHROPIC_* variables are inherited correctly when not explicitly set. This resolves potential nil map issues on resumed sessions.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. hld/session/manager.go:1746
  • Draft comment:
    Consider refactoring the common ANTHROPIC environment variable injection logic into a helper function to avoid duplication between LaunchSession and ContinueSession.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_cRsk06FATLXf949O

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@dexhorthy
Copy link
Contributor

thanks - okay so it does work from CLI?

I think this approach is fine. At a certain point we need a more complete design around env vars, since you may want arbitrary vars to be passed in at a global, per-project, or per-session level

@VAIBHAVSING
Copy link
Contributor Author

@dexhorthy is there any thing need to change from there please give me in brief

Copy link
Contributor

@dexhorthy dexhorthy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like the correct implementation - can you add a unit test for the config.go changes just to prove out some basic happy-path examples?

@dexhorthy
Copy link
Contributor

dexhorthy commented Oct 6, 2025

I have tested this with a LINEAR_API_KEY and it works, and the tests are close. One last thing - I'd like us to have coverage/demonstration in the tests on what is the behavior when env vars are set and config.json has values - what takes precedence?

e.g.

  1. set ANTHROPIC_BASE_URL in env
  2. set different ANTHROPIC_BASE_URL in config json
  3. open /Applications/CodeLayer-Nightly.app
  4. which one is used?

I think env vars + launching with open should take precedence over ~/.config/humanalyer/.... but I'm open to discussion. This probably should be decided before we proceed. @K-Mistele any thoughts? I think convention would dictate deferring to env vars over config file, but maybe this is also a bit of a corner case if people start primarily launching from Spotlight/Raycast because we have this feature now

@VAIBHAVSING
Copy link
Contributor Author

@dexhorthy I am developing on ubantu ,I am launching through cd humanlayer-wui && bun dev and also used from tauri

@dexhorthy
Copy link
Contributor

okay thanks - does my question about adding more unit tests for env var override behavior make sense?

Add comprehensive unit tests for the config.go Env map functionality:
- Test case preservation for environment variable keys (ANTHROPIC_BASE_URL, AWS_REGION, etc.)
- Test handling of missing env section
- Test empty env object behavior
- Test save/load round-trip preservation
- Test special characters in env values (URLs, paths, spaces)

These tests validate that the case-sensitive environment variable
configuration works correctly for Bedrock and other Anthropic-compatible
endpoints.
- Properly handle error returns in deferred cleanup functions
- Remove unnecessary nil check for cfg.Env (len() is safe on nil maps)
- Fixes errcheck and staticcheck linter warnings
@dexhorthy
Copy link
Contributor

@VAIBHAVSING sorry for the delay here - I've just found that claude supports env vars in .claude/settings.json or .claude/settings.local.json or ~/.claude/settings.json -

see the env key here

for now we will advise folks to use this instead of having env var management in the product

I super appreciate your contribution and hope that us closing won't dissuade you from contributing in the future.

https://docs.claude.com/en/docs/claude-code/settings#available-settings

@dexhorthy dexhorthy closed this Oct 15, 2025
@VAIBHAVSING VAIBHAVSING deleted the inherit_Anthropic branch October 16, 2025 03:23
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.

Add inference support for Claude on AWS Bedrock

3 participants