feat: Agent Self-Replication, Self-Recoding, and Telepathy (sub-issues 9-11)#6
Merged
kingassune merged 2 commits intomainfrom Feb 24, 2026
Merged
Conversation
…ssues 9-11) Co-authored-by: kingassune <6126851+kingassune@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add agent self-replication functionality
feat: Agent Self-Replication, Self-Recoding, and Telepathy (sub-issues 9-11)
Feb 24, 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.
📝 Description
Implements three new Living Agent capabilities: self-replication (spawn child agents inheriting config/skills/memory with mutated trading strategies), self-recoding (runtime config self-modification gated by goodwill), and telepathy (in-process + file-based pub/sub between parent and child agents).
pkg/replication/replicator.go—Replicatordeep-copies parent config via JSON round-trip, assigns unique gateway port (parentPort + childIndex), splits GMAC balance byGMACSharePercent, recursively copiesskills/andmemory/dirs. Goodwill check is interface-based (func() int) so it compiles without Phase 2 merged.mutation.go—mutateSystemPrompt()picks randomly from 8 strategy archetypes (contrarian, momentum, HFT, risk-averse, etc.). Mutation is written toTRADING_STRATEGY.mdin the child workspace — picked up automatically byLoadBootstrapFiles.persistence.go— Atomic save/load ofreplication/children.jsonvia temp+rename.telepathy.go— In-processTelepathyBus: broadcast, point-to-point send, subscribe/unsubscribe, 500-msg ring buffer history,BroadcastTradeSignalconvenience method.telepathy_file.go— File-based telepathy for multi-process agents: poll-based watcher, JSON message files named{ts}-{agent}.json, configurable poll interval and message TTL (default 2s / 1h).pkg/recode/recoder.go—RecodersupportsModifySystemPrompt(appends torecode/prompt_additions.txt),AddCronJob,InstallSkill,AdjustTradingParams(patchesGDEXConfigfields by name). All actions are logged withRecodeAction;Rollback(index)marks an entry un-approved.pkg/tools/gdex_replicate.go—replicatetool: goodwill-gated, callsReplicator.Replicate(), returns child descriptor JSON.gdex_recode.go—self_recodetool: dispatchesmodify_prompt | add_cron | install_skill | adjust_trading; cron/skill args useSCHEDULE|TASKpipe convention, trading params accept JSON.gdex_telepathy.go—telepathytool: broadcast or targeted send viaTelepathyBus; defaultsto="*",priority=1.🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
Parent epic: #3
📚 Technical Context (Skip for Docs)
pkg/metabolism/metabolism.go,pkg/bus/bus.go,pkg/agent/context.gofunc() intcallbacks rather than direct*Metabolismreferences so all three packages build independently of the Phase 2 metabolism/goodwill merge. Mutations land inTRADING_STRATEGY.mdbecauseLoadBootstrapFilesalready scans the workspace for markdown files — no agent loop changes required.🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
☑️ Checklist
Original prompt
Parent Epic: #3 — Living Agent — GMAC Metabolism, GDEX SDK Trading, Self-Replication, Telepathy
This PR covers sub-issues 9-11 from the epic: Agent Self-Replication, Agent Self-Recoding, and Telepathy (Parent-Child Agent Communication).
Important: This PR should be buildable independently. Where it references the metabolism/goodwill system from Phase 2, use interfaces so it compiles even if Phase 2 hasn't merged yet.
Sub-Issue 9: Agent Self-Replication
When an agent's goodwill score crosses the replication threshold (default 50), it earns the ability to clone itself into a new persistent Gclaw instance.
New Package:
pkg/replication/File:
pkg/replication/replicator.goImplement these methods:
NewReplicator(parentID string, config ReplicationConfig) *ReplicatorCanReplicate(goodwill int, threshold int) boolReplicate(parentConfig *config.Config, parentWorkspace string, parentGMAC float64) (*ChildAgent, error):gclaw-child-{timestamp})ChildWorkspaceDirMutatePromptis true, callmutateSystemPrompt()to add a random trading strategy variationInheritSkillsis true, copy{parentWorkspace}/skills/to child workspaceInheritMemoryis true, copy{parentWorkspace}/memory/to child workspaceGMACSharePercentfrom parent, give to childChildAgentstructListChildren() []*ChildAgentGetChild(id string) (*ChildAgent, bool)StopChild(id string) errorFile:
pkg/replication/mutation.goMutations should be selected randomly from a pool:
The mutation gets appended to the child's system prompt, creating natural diversity.
File:
pkg/replication/persistence.goSaveChildren(path string) error— persist children list to{workspace}/replication/children.jsonLoadChildren(path string) error— restore on startupNew Tool:
pkg/tools/gdex_replicate.goCreate a
ReplicateToolthat the agent can call:replicatename(string, optional — label for the child),strategy_hint(string, optional — influence the mutation)Replicator.Replicate(), return child infoSub-Issue 10: Agent S...
This pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.