Repository navigation
feat(core): reload agents from config change feed - #39167
Merged
Merged
Conversation
This was referenced Jul 27, 2026
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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.
What
Agent source invalidation via
config.changes: editing, creating, renaming, or deleting Markdown files under a config root's{agent,agents}or legacy{mode,modes}directories now rebuilds agent state directly, without aconfig.updatedevent that descendant edits never trigger. Fifth slice of the config source reload series (#38983, #39131, #39157, #39160).How
Same seam as the command plugin in #39160, with two refinements from review:
Stream.merge(sourceChanges, configUpdates)feeds a single debounce and a singlerunForEach, so filesystem invalidations and structuredconfig.updatedreloads are serialized on one fiber — no duplicateload()scans on correlated bursts and no stale-scan overwrite ofloaded.documents.FSUtil.containsfor path containment (Windows-robust, same helper Config's ownreconcileuses), driven by onesourceDirectoriesconstant colocated withlegacySourcesinstead of a second literal name list.The predicate matches anything at or under
<root>/{agent,agents,mode,modes}with no file-suffix check, so directory-level renames that carry no per-file paths still invalidate. The subscription forks before the initial scan.New shared test helpers land in
test/lib/clock.ts(advance,drain): bothStream.debounce(100ms) andState.reload(500ms batch) register TestClock sleeps from fiber hops a singleTestClock.adjustflush can miss, so the helpers alternate real-macrotask settles with adjusts until the asserted condition holds.Testing
Source-lifecycle matrix using the #39157 fixtures (
Config.testLayer+Config.Test.emitChange):modesdirectory (assertsmode: "primary"), each verifying inside theagent.updatedsubscription so the event is asserted as a read barrier.commands/path) produce zero rebuilds, and the feed stays live afterwards.Red first (all 7 fail without the fix), green with it; stable across 10 consecutive runs.
bun test test/config/passes except the pre-existingPluginSupervisorfailure present on clean base;bun typecheckclean.Follow-ups
FSUtil.containsshape and migratecommand.test.ts's inline clock helpers totest/lib/clock.ts(deferred from feat(core): reload commands from config change feed #39160 to avoid review churn).reload, precedented byConfig.reload) — needs its own red test, applies to both plugins.