fix: Improve DX for getting port for agent (#221)

* fix: Improve DX for getting port for agent

* docs
This commit is contained in:
Brace Sproul 2025-06-18 11:58:15 -07:00 • committed by GitHub
parent ac9f6a3986
commit 38dc6ebdf4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View file

@ -52,6 +52,10 @@ DAYTONA_API_KEY=""
GITHUB_TOKEN_ENCRYPTION_KEY=""
# Used for setting the git user name & email for commits.
GITHUB_APP_NAME="open-swe-dev"
# Defaults to 2024 if not set.
# LGP will automatically set this for you in production.
# PORT="2024"
```
And the web `.env` file should contain the following variables:

View file

@ -16,4 +16,8 @@ DAYTONA_API_KEY=""
# Should be the same value as the one used in the web app.
GITHUB_TOKEN_ENCRYPTION_KEY=""
# Used for setting the git user name & email for commits.
GITHUB_APP_NAME="open-swe-dev"
GITHUB_APP_NAME="open-swe-dev"
# Defaults to 2024 if not set.
# LGP will automatically set this for you in production.
# PORT="2024"

View file

@ -4,9 +4,7 @@ export function createLangGraphClient(options?: {
defaultHeaders?: Record<string, string>;
includeApiKey?: boolean;
}) {
if (!process.env.PORT) {
throw new Error("PORT environment variable not found");
}
const port = process.env.PORT ?? "2024";
if (options?.includeApiKey && !process.env.LANGGRAPH_API_KEY) {
throw new Error("LANGGRAPH_API_KEY not found");
}
@ -14,7 +12,7 @@ export function createLangGraphClient(options?: {
...(options?.includeApiKey && {
apiKey: process.env.LANGGRAPH_API_KEY,
}),
apiUrl: `http://localhost:${process.env.PORT}`,
apiUrl: `http://localhost:${port}`,
defaultHeaders: options?.defaultHeaders,
});
}