Skip to content

feat: forward known AI agent ENVs on exec, fixes #8378#8380

Open
AkibaAT wants to merge 1 commit intoddev:mainfrom
AkibaAT:20260502_akibaat_forward_ai_agent_info
Open

feat: forward known AI agent ENVs on exec, fixes #8378#8380
AkibaAT wants to merge 1 commit intoddev:mainfrom
AkibaAT:20260502_akibaat_forward_ai_agent_info

Conversation

@AkibaAT
Copy link
Copy Markdown
Contributor

@AkibaAT AkibaAT commented May 1, 2026

The Issue

How This PR Solves The Issue

Forward the well-known agent ENVs listed in https://github.com/laravel/agent-detector#supported-agents on exec to all DDEV services.

Apart from COPILOT_GITHUB_TOKEN. I don't think we should automatically forward authentication information like that.

Manual Testing Instructions

  • Start any DDEV project.
  • Run:
    AI_AGENT=manual-test ddev exec 'echo $AI_AGENT'
    AI_AGENT=manual-test ddev exec -s db 'echo $AI_AGENT'
    

Expected result: both commands print manual-test.

Automated Testing Overview

go test -v ./pkg/ddevapp -run 'TestAgentDetectionEnv'

Release/Deployment Notes

@AkibaAT AkibaAT requested a review from a team as a code owner May 1, 2026 23:37
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Member

@rfay rfay 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 to be great. Could it be made more general? I'm sure that other environment variables would be lovely to have sometimes. It's possible we should have a global or project config to say what env vars to deliver to in-container environments.

@AkibaAT
Copy link
Copy Markdown
Contributor Author

AkibaAT commented May 4, 2026

Making it configurable in some way does sound like a good idea. Defaults plus extendable overrides?

@rfay
Copy link
Copy Markdown
Member

rfay commented May 4, 2026

Defaults plus extendable overrides?

Makes sense to me.

However, I'm not sure the agent environment variables are the default starters, people could add those as needed.

@AkibaAT
Copy link
Copy Markdown
Contributor Author

AkibaAT commented May 4, 2026

However, I'm not sure the agent environment variables are the default starters, people could add those as needed.

Hmmm... well, the feature ticket explicitly asked for it: "We should have first-class support for this - users shouldn't have to do extra work for it."

@rfay
Copy link
Copy Markdown
Member

rfay commented May 4, 2026

Hmmm... well, the feature ticket explicitly asked for it: "We should have first-class support for this - users shouldn't have to do extra work for it."

It's true. But the need is far more general and the AI usage seems like a tiny piece of it. But let's let @stasadev weigh in here.

Copy link
Copy Markdown
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

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

The env pass for ddev exec looks good.

I haven't tested it yet - I'll do it during the week.

This looks to be great. Could it be made more general? I'm sure that other environment variables would be lovely to have sometimes. It's possible we should have a global or project config to say what env vars to deliver to in-container environments.

We already have a passthrough in ddev start, added in v1.25.2:

DDEV could read globalconfig.DdevGlobalConfig.WebEnvironment + app.WebEnvironment during ddev exec and look up env vars declared as bare variables.

This feels like a natural flow to me and wouldn't require any new config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass environment variables (i.e. AI_AGENT) for AI detection inside web container

3 participants