Skip to content

feat: migrate template runtime support to AgentSeek API - #172

Open
kic635 wants to merge 8 commits into
ob-labs:mainfrom
kic635:codex/agentseek-api-runtime
Open

feat: migrate template runtime support to AgentSeek API#172
kic635 wants to merge 8 commits into
ob-labs:mainfrom
kic635:codex/agentseek-api-runtime

Conversation

@kic635

@kic635 kic635 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR provides the AgentSeek lifecycle support required by the LangGraph CLI to AgentSeek API template migration tracked in #170.

  • Pass project env_file values to long-running agentseek dev child processes.
  • Preserve shell environment precedence over .env.
  • Expose lifecycle service runtime metadata such as agentseek-api in human and JSON output.
  • Use the standards-compliant dotenv parser used by settings/readiness.
  • Reconcile lifecycle documentation and add CLI/lifecycle regression coverage.

Related PRs and merge order

  1. A follow-up AgentSeek API runtime change must ensure its langgraph.json dotenv load cannot overwrite the shell values that this PR passes to children.
  2. This PR supplies the AgentSeek CLI lifecycle behavior.
  3. feat: migrate selected templates to AgentSeek API agentseek-ai/agentseek-templates#14 migrates template commands and depends on both layers for the documented shell-over-.env contract.

Validation

  • 264 passed in lifecycle test suites
  • ruff check for changed lifecycle modules and tests
  • git diff --check

Tracking

Related: #170. Issue #170 remains open while the runtime follow-up is merged and released and the template companion PR is merged.

@kic635 kic635 changed the title fix: pass template env to dev child processes feat: migrate template runtime support to AgentSeek API Aug 10, 2026

@webup webup left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes at 55d5bda284170430e618e407e2698bf9de1fc21d.

The hosted checks are green, but the migration contract still has user-visible regressions:

  1. Use consistent dotenv semantics for child processes. The new _read_env_file() only strips outer quotes. Values containing inline comments or quoted escapes can therefore pass doctor with one value and reach the child with a different literal value. Please reuse the same standards-compliant dotenv parser used by settings/readiness, and cover comments, quotes, escapes, and export.
  2. Preserve v1 service tech in normalized/JSON output. ServiceV1.tech is now accepted and shown by human output, but _v1_services_and_checks() still constructs NormalizedService(tech=None). As a result, agentseek info and agentseek info --json disagree.
  3. Reconcile all lifecycle documentation. The updated reference says .env is injected into agentseek dev children, while other maintained documentation still says it is never injected.
  4. Verify shell precedence through the target runtime. AgentSeek applies the shell last, but agentseek-api subsequently reloads the langgraph.json env file and overwrites inherited values. The composed path therefore does not satisfy this PR's shell-wins promise. Please coordinate the runtime fix and add a cross-repository regression test.

Because the companion template migration does not yet start successfully from a fresh generated project, Closes #170 is also premature.

@kic635

kic635 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the detailed review. Addressed in 0840315:

  1. Child processes now use pydantic-settings' dotenv_values parser, matching settings/readiness semantics. Regression coverage includes inline comments, quoted escaped newlines, export declarations, and a real spawned child process.
  2. The v1 normalization projection now preserves ServiceV1.tech, with an exact agentseek info --json regression assertion.
  3. Reconciled the maintained English and Chinese lifecycle/get-started/template-authoring documentation: project env_file values go to long-running dev children; lifecycle defaults do not; exported shell values win.
  4. The CLI layer now applies shell values last. The remaining target-runtime half (preventing agentseek-api from reapplying langgraph.json dotenv values over the inherited shell) must land and be released before this migration can claim the full shell-wins contract. The PR description records that as an explicit merge prerequisite.

Also removed the premature Closes #170; the PR now links it as Related until the runtime follow-up and template companion PR have landed.

Validation: 264 lifecycle tests passed, ruff passed for changed lifecycle code/tests, and git diff --check passed.

@webup webup left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes at 08403159b203f76263fd7e272799f03ef7b4f1a6.

Thanks for fixing the dotenv syntax cases, v1 tech projection, real-child coverage, and the conflicting lifecycle docs. The hosted suite is green, but the migration still has these blockers:

  1. [P1] Keep every declared-supported installation importable. core.py imports pydantic_settings.sources.providers.dotenv, an internal path that is absent from the declared minimum pydantic-settings==2.0.0. A clean Python 3.13 floor install currently fails before agentseek --help can start with ModuleNotFoundError. Please use a public API and declare its package directly, or raise the minimum to the first compatible version and test that exact floor in CI. The same import should also be corrected before the coordinated API runtime is released.
  2. [P1] Deliver shell-over-.env precedence through the actual runtime. AgentSeek now produces a child environment with the shell value, but published agentseek-api==0.2.1 reloads langgraph.json's env file afterward. The exact composed result remains child=from-shell, runtime=from-dotenv. API PR #69 produces the desired result, but it is still open, has no completed checks, and no fixed release exists. Please land and release the runtime fix, require that release from the migrated templates, and add one composed agentseek dev regression with conflicting values.
  3. [P2] Keep the guide aligned with the immutable catalog. The English and Chinese template guides say locked langchain/markdown-messages uses agentseek-api dev, while this repository still pins catalog commit 494863bc..., whose lifecycle runs langgraph dev. Revert the claim until the companion template commit is merged and this repository's lock/snapshot is updated to it.
  4. [P2] Make empty-value precedence consistent. Readiness uses env_ignore_empty=True, so exported FOO="" falls back to .env; _process_environment() then passes the empty shell value to the child. doctor can therefore pass on one value while the backend receives another. Choose and document one rule, then assert the same resolved value in readiness and the spawned child.
  5. [P2] Do not close #170 before the cross-repository migration is complete. Editing the body to say "Related" did not remove GitHub's closing association: live closingIssuesReferences still contains #170. Please remove that association until the runtime release, template migration, catalog update, and composed smoke are complete.

Suggested pre-commit gate:

set -euo pipefail
export UV_CACHE_DIR="$(mktemp -d)/uv-cache"

# Test the exact dependency floor declared in pyproject.toml.
uv run --python 3.13 --isolated --no-project \
  --with-editable . \
  --with pydantic-settings==2.0.0 \
  agentseek --help

# Exercise all lifecycle behavior and documentation touched by this PR.
uv run --locked python -m pytest -q \
  tests/cli_commands/test_lifecycle.py \
  tests/cli_commands/test_lifecycle_authored.py \
  tests/cli_commands/test_lifecycle_json.py \
  tests/cli_commands/test_lifecycle_normalization.py \
  tests/cli_commands/test_lifecycle_safety.py \
  tests/test_docs_lifecycle.py \
  tests/cli_commands/test_locked_catalog.py

uv run --locked ruff check src/agentseek/cli/lifecycle tests/cli_commands tests/test_docs_lifecycle.py
uv run --locked ruff format --check src/agentseek/cli/lifecycle tests/cli_commands tests/test_docs_lifecycle.py
git diff --check

# This must be zero before merge.
gh pr view 172 --repo ob-labs/agentseek \
  --json closingIssuesReferences \
  --jq '.closingIssuesReferences | length'

Expected results: CLI floor import exits 0; tests/lint/format/diff checks have zero failures; the closing count is 0. Also add these behavioral assertions to CI rather than relying only on local output:

  • .env: FOO=from-dotenv plus shell FOO="" yields the same documented value in readiness and the child.
  • A freshly rendered migrated template launched through agentseek dev sees SENTINEL=from-shell when .env contains SENTINEL=from-dotenv.
  • The composed smoke prints a fixed agentseek-api release version, reaches /health, and completes assistant -> thread -> run -> wait with status=success.
  • The catalog commit actually used by the wheel has the lifecycle command described by both guides.

@kic635

kic635 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the detailed review. Commit 8eee57077ea190f60727798e0216069caed46474 addresses the migration issues that are independent of the agentseek-api release:

  • Replaced the internal pydantic_settings dotenv import with the public python-dotenv API and declared the dependency directly. The exact Python 3.13 / pydantic-settings==2.0.0 agentseek --help floor check passes in CI.
  • Made empty exported environment values follow the documented rule: empty shell values are treated as unset, so readiness and the spawned child both resolve the value from .env. Added a real-child regression test.
  • Restored both template guides to langgraph dev, matching the catalog commit currently locked by this repository.
  • Removed the closing association with Migrate selected templates from langgraph dev to agentseek-api #170; closingIssuesReferences is now empty.

The remaining runtime blocker is intentionally not claimed as fixed here. Published agentseek-api==0.2.1 reloads the env file after AgentSeek composes the child environment. The end-to-end shell-over-.env behavior therefore requires agentseek-api PR #69 to merge and release first. After that release, this PR still needs the migrated template dependency/catalog update and the composed assistant -> thread -> run -> wait smoke. Those checks cannot provide a meaningful result against the current runtime release, so they remain pending rather than being papered over in this change.

The requested lifecycle/docs tests, lint, formatting, diff check, lock check, and minimum-floor CLI check pass for this commit.

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.

2 participants