Repository navigation
feat(core): add agent factory, OpenAI models, skills, context (ENG-380) - #3
Merged
folathecoder merged 1 commit intoOct 17, 2026
Conversation
Assemble Aldwin's Agentling agent, session helpers, and mid-session model switching in aldwin.core.agent, with skill validation from ~/.aldwin/skills/ and package-shipped base instructions. Add build_context in aldwin.core.context to rebuild the system message on every model call (base instructions, skill catalog, capped persona, and memory block seam) and trim conversation history to the last 20 user exchanges without splitting tool calls from their tool results. Add check_key, list_chat_models, classify_model_error, and RetryingModel in aldwin.core.models with 3 exponential-backoff retries (1s, 2s, 4s +- 20%) and wire non-terminal StatusEvent notifications into AldwinHost.
folathecoder
deleted the
eng-380-4-agent-core-agentling-openai-skills-and-context
branch
October 17, 2026 01:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds
aldwin.core: the Agentling agent and session factory, progressive skill loading and validation from~/.aldwin/skills/, the per-call context manager that rebuilds the system message and trims history to 20 user exchanges, and OpenAI key checking, model discovery, and 3-attempt exponential-backoff retries. Wiresaldwin.coreintoAldwinHostand addsStatusEventtoaldwin.protocolso retry notices reach the door without polluting streamed assistant text.Ticket
Changes
src/aldwin/core/agent.py,src/aldwin/core/assets/instructions.md):load_base_instructions(),load_skills(),build_agent(),new_session(),restore_session(),rebuild_agent(), andswitch_session_model().SKILL.mdfrontmatter, enforced first-wins on duplicate skill names, rejectedtools:entry points and reserved tool names in0.0.1, and recordedInvalidSkillitems for/skills.src/aldwin/core/context.py):build_context(home, limits),read_persona_stub(home, cap), andmemory_block_stub(home, limits).messages[0]on every model call (instructions+## Personacapped at 2,000 chars +<memory>block) and trimmed history to the last 20 user turns while keeping assistant tool calls and theirtoolresult messages together.src/aldwin/core/models.py):check_key()(ok,invalid,no_access,network_errorwith 10 s timeout),list_chat_models()(chat-capable filter, sorted newest first),classify_model_error(),RetryingModel(3 retries with1s, 2s, 4s +- 20%jitter,on_retrycallback, no retry on auth errors or after mid-stream chunks), andbuild_openai_model().src/aldwin/protocol/messages.py,src/aldwin/host/runner.py,docs/protocol.md):StatusEvent(kind="status", message=...)toaldwin.protocol.AldwinHosttobuild_agent,new_session,restore_session,switch_session_model,classify_model_error, andRetryingModel.on_retry.tests/test_context.py,tests/test_models.py,tests/test_agent.py,tests/integration/test_core_host.py,tests/live/test_openai_live.py,tests/test_architecture.py):-m livetest suites coveringTC-01throughTC-20.How it was tested
uv run pytest --cov=aldwin --cov-report=term-missing: 118 passed, 1 deselected in 0.63s (94% total coverage;core/agent.py98%,core/context.py92%,core/models.py90%).uv run ruff check src testsanduv run ruff format --check src tests: passed.uv run mypy src testsanduv run mypy --strict src/aldwin/core src/aldwin/protocol: passed (0 issues across 36 files).TC-12) can be run withOPENAI_API_KEY=<key> uv run pytest -m live -v.Notes for reviewers
read_persona_stubandmemory_block_stubinsrc/aldwin/core/context.pyprovide the seams thatENG-381(core/persona.pyandcore/memory.py) will plug into.build_agentacceptstools: Sequence[Tool](defaulting to()) ready forENG-381andENG-382(builtin_tools).