Skip to content

[Feature Request] Support Loading Configuration from .env Files and Environment Variables #70

@xuehuitian45

Description

@xuehuitian45

Description

Currently, the AgentScope Java Runtime primarily loads configuration by hardcoded values. This makes it difficult to:

  • Inject secrets (e.g., API keys, access tokens) securely in containerized or cloud environments
  • Customize behavior per environment (dev/staging/prod) without rewriting codes

To improve usability in CI/CD, Kubernetes, and local development workflows, we propose adding native support for:

  1. Loading environment variables (e.g., AGENTRUN_ACCESS_KEY)
  2. Parsing .env files (e.g., ./agentscope.env or .env in working directory)

This aligns with common practices in modern Java frameworks (e.g., Spring Boot, Quarkus) and matches the flexibility already available in the Python runtime.

Proposed Behavior

Priority Order (Highest to Lowest)

  1. Environment variables (e.g., AGENTSCOPE_TOOL_PAYMENT_MERCHANT_ID)
  2. .env file (optional, auto-loaded if present)
  3. config file (config.yaml)

Benefits

  • Secure secret management (no hard-coded keys)
  • Seamless transition from local → cloud deployment
  • Easier testing with different configs
  • Consistency with Python runtime and industry standards

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions