{"record":{"id":"058b75d120216021","repo":"chenhg5/cc-connect","slug":"get-relay-workspace-agent-w","errorCode":null,"errorMessage":"get relay workspace agent: %w","messagePattern":"get relay workspace agent: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":15951,"sourceCode":"\tif !e.multiWorkspace || e.workspaceBindings == nil {\n\t\treturn e.agent, e.sessions, relaySessionKey, nil\n\t}\n\n\tchannelKey := workspaceChannelKey(platformName, chatID)\n\tworkspace, _, err := e.resolveWorkspace(e.platformForName(platformName), chatID)\n\tif err != nil {\n\t\treturn nil, nil, \"\", fmt.Errorf(\"resolve relay workspace: %w\", err)\n\t}\n\tif workspace == \"\" {\n\t\tif b, _, usable := e.lookupEffectiveWorkspaceBinding(channelKey); b != nil && !usable {\n\t\t\treturn nil, nil, \"\", fmt.Errorf(\"workspace binding unavailable for source channel %q\", channelKey)\n\t\t}\n\t\treturn nil, nil, \"\", fmt.Errorf(\"no workspace binding for source channel %q\", channelKey)\n\t}\n\n\tagent, sessions, err := e.getOrCreateWorkspaceAgent(workspace)\n\tif err != nil {\n\t\treturn nil, nil, \"\", fmt.Errorf(\"get relay workspace agent: %w\", err)\n\t}\n\tif ws := e.workspacePool.Get(workspace); ws != nil {\n\t\tws.Touch()\n\t}\n\treturn agent, sessions, relaySessionKey, nil\n}\n\n// HandleRelay processes a relay message synchronously: starts or resumes a\n// dedicated relay session, sends the message to the agent, and blocks until\n// the complete response is collected (or the relay context times out).\nfunc (e *Engine) HandleRelay(ctx context.Context, fromProject, sourceSessionKey, message string) (string, error) {\n\tagent, sessions, relaySessionKey, err := e.relayContextForSourceSessionKey(fromProject, sourceSessionKey)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tsession := sessions.GetOrCreateActive(relaySessionKey)\n\n\tif inj, ok := agent.(SessionEnvInjector); ok {","sourceCodeStart":15933,"sourceCodeEnd":15969,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L15933-L15969","documentation":"After the relay target workspace was resolved, getOrCreateWorkspaceAgent(workspace) failed to create or fetch the agent instance bound to that workspace; the cause is wrapped as 'get relay workspace agent: %w'. This means routing succeeded but the per-workspace agent could not be instantiated (e.g. agent type unknown, initialization error, resource limits).","triggerScenarios":"e.getOrCreateWorkspaceAgent(workspace) returns an error during relay — the configured agent type for the workspace is not registered (excluded via build tag), the agent factory fails (bad options), or creating the SessionManager for the workspace fails (unwritable directory).","commonSituations":"Agent binary (claude, codex, gemini CLI) missing from PATH; workspace agent type removed from build via no_* tags; state directory for the workspace not writable; invalid agent options in the workspace config block.","solutions":["Read the wrapped cause to see whether registration, factory, or filesystem failed","Verify the agent CLI binary exists in PATH (cc-connect doctor can help)","Check that the agent type is compiled in (not excluded by no_* build tags)","Validate the workspace's agent config options in config.toml","Ensure the workspace state directory is writable by the process user"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// startup check: agent binary reachable\nbin := \"claude\" // from workspace agent config\nif _, err := exec.LookPath(bin); err != nil {\n    slog.Error(\"agent binary not in PATH\", \"bin\", bin)\n}","typeGuard":null,"tryCatchPattern":"agent, sessions, err := e.getOrCreateWorkspaceAgent(workspace)\nif err != nil {\n    slog.Error(\"workspace agent unavailable\",\n        \"workspace\", workspace, \"cause\", errors.Unwrap(err))\n    return nil, nil, \"\", fmt.Errorf(\"get relay workspace agent: %w\", err)\n}","preventionTips":["Run cc-connect doctor at startup to verify agent binaries and credentials","Keep agent CLI installations and versions consistent across workspaces","Ensure workspace state directories exist and are writable before first use","Avoid excluding agent packages via build tags that workspaces reference"],"tags":["agent","workspace","relay","initialization"],"backgroundTag":"missing-dependency","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}