MCPcopy Index your code
hub / github.com/anomalyco/opencode / reduceSubagentData

Function reduceSubagentData

packages/opencode/src/cli/cmd/run/subagent-data.ts:792–876  ·  view source on GitHub ↗
(input: {
  data: SubagentData
  event: Event
  sessionID: string
  thinking: boolean
  limits: Record<string, number>
})

Source from the content-addressed store, hash-verified

790}
791
792export function reduceSubagentData(input: {
793 data: SubagentData
794 event: Event
795 sessionID: string
796 thinking: boolean
797 limits: Record<string, number>
798}) {
799 const event = input.event
800
801 if (event.type === "message.part.updated") {
802 const part = event.properties.part
803 if (part.sessionID === input.sessionID) {
804 if (part.type !== "tool") {
805 return false
806 }
807
808 return syncTaskTab(input.data, part)
809 }
810 }
811
812 const sessionID =
813 event.type === "message.updated" ||
814 event.type === "message.part.delta" ||
815 event.type === "permission.asked" ||
816 event.type === "permission.replied" ||
817 event.type === "question.asked" ||
818 event.type === "question.replied" ||
819 event.type === "question.rejected" ||
820 event.type === "session.error" ||
821 event.type === "session.status"
822 ? event.properties.sessionID
823 : event.type === "message.part.updated"
824 ? event.properties.part.sessionID
825 : undefined
826
827 if (!sessionID || !knownSession(input.data, sessionID)) {
828 return false
829 }
830
831 const detail = ensureDetail(input.data, sessionID)
832 const cancelled =
833 event.type === "message.updated" && isAbortedAssistantMessage(event.properties.info)
834 ? cancelSubagentTab(input.data, sessionID)
835 : false
836 if (event.type === "session.status") {
837 if (event.properties.status.type !== "retry") {
838 return cancelled
839 }
840
841 return (
842 appendCommits(detail, [
843 {
844 kind: "error",
845 text: event.properties.status.message,
846 phase: "start",
847 source: "system",
848 messageID: `retry:${event.properties.status.attempt}`,
849 },

Callers 2

reduceFunction · 0.90
createLayerFunction · 0.90

Calls 8

formatErrorFunction · 0.90
syncTaskTabFunction · 0.85
knownSessionFunction · 0.85
ensureDetailFunction · 0.85
cancelSubagentTabFunction · 0.85
appendCommitsFunction · 0.85
applyChildEventFunction · 0.85

Tested by 1

reduceFunction · 0.72