1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[12203],{8667:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>a});var i=t(22155);const s={},o=i.createContext(s);function r(e){const n=i.useContext(o);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(o.Provider,{value:n},e.children)}},11069:(e,n,t)=>{t.d(n,{u:()=>p,v:()=>d});var i=t(22155),s=t(62934),o=t(17515),r=t(65363),a=t(59572),l=t(8528);function d(e){return i.Children.toArray(e).filter(e=>"\n"!==e).map(e=>{if(!e||(0,i.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})?.filter(Boolean)??[]}function c(e){const{values:n,children:t}=e;return(0,i.useMemo)(()=>{const e=n??function(e){return d(e).map(({props:{value:e,label:n,attributes:t,default:i}})=>({value:e,label:n,attributes:t,default:i}))}(t);return function(e){const n=(0,l.XI)(e,(e,n)=>e.value===n.value);if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map(e=>e.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e},[n,t])}function u({value:e,tabValues:n}){return n.some(n=>n.value===e)}function h({queryString:e=!1,groupId:n}){const t=(0,s.W6)(),o=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:e,groupId:n});return[(0,r.aZ)(o),(0,i.useCallback)(e=>{if(!o)return;const n=new URLSearchParams(t.location.search);n.set(o,e),t.replace({...t.location,search:n.toString()})},[o,t])]}function p(e){const{defaultValue:n,queryString:t=!1,groupId:s}=e,r=c(e),[l,d]=(0,i.useState)(()=>function({defaultValue:e,tabValues:n}){if(0===n.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!u({value:e,tabValues:n}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}const t=n.find(e=>e.default)??n[0];if(!t)throw new Error("Unexpected error: 0 tabValues");return t.value}({defaultValue:n,tabValues:r})),[p,x]=h({queryString:t,groupId:s}),[f,g]=function({groupId:e}){const n=function(e){return e?`docusaurus.tab.${e}`:null}(e),[t,s]=(0,a.Dv)(n);return[t,(0,i.useCallback)(e=>{n&&s.set(e)},[n,s])]}({groupId:s}),j=(()=>{const e=p??f;return u({value:e,tabValues:r})?e:null})();(0,o.A)(()=>{j&&d(j)},[j]);return{selectedValue:l,selectValue:(0,i.useCallback)(e=>{if(!u({value:e,tabValues:r}))throw new Error(`Can't select invalid tab value=${e}`);d(e),x(e),g(e)},[x,g,r]),tabValues:r}}},17601:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>p,frontMatter:()=>l,metadata:()=>i,toc:()=>u});const i=JSON.parse('{"id":"sidekick-studio/agentflows/sequential-agents/condition-node","title":"Condition Node","description":"Understanding the Condition Node in Sequential Agents","source":"@site/docs/sidekick-studio/agentflows/sequential-agents/condition-node.md","sourceDirName":"sidekick-studio/agentflows/sequential-agents","slug":"/sidekick-studio/agentflows/sequential-agents/condition-node","permalink":"/docs/sidekick-studio/agentflows/sequential-agents/condition-node","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{"description":"Understanding the Condition Node in Sequential Agents"},"sidebar":"docs","previous":{"title":"Condition Agent Node","permalink":"/docs/sidekick-studio/agentflows/sequential-agents/condition-agent-node"},"next":{"title":"End Node","permalink":"/docs/sidekick-studio/agentflows/sequential-agents/end-node"}}');var s=t(65723),o=t(8667),r=t(51580),a=t(72474);const l={description:"Understanding the Condition Node in Sequential Agents"},d="Condition Node",c={},u=[{value:"Understanding the Condition Node",id:"understanding-the-condition-node",level:2},{value:"Inputs",id:"inputs",level:2}
1,{value:"Outputs",id:"outputs",level:2},{value:"Features",id:"features",level:2},{value:"JavaScript Expression Evaluation",id:"javascript-expression-evaluation",level:3},{value:"Dynamic Workflow Routing",id:"dynamic-workflow-routing",level:3},{value:"Best Practices",id:"best-practices",level:2}];function h(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"condition-node",children:"Condition Node"})}),"\n",(0,s.jsxs)(n.p,{children:["The Condition Node is a ",(0,s.jsx)(n.strong,{children:"specialized node that enables branching logic in Sequential Agent workflows"}),". It evaluates a condition based on the current State (conversation history and custom State) and directs the flow to one of two possible output paths depending on whether the condition is true or false."]}),"\n",(0,s.jsx)(n.h2,{id:"understanding-the-condition-node",children:"Understanding the Condition Node"}),"\n",(0,s.jsx)(n.p,{children:"The Condition Node acts as a decision point in your workflow, allowing different execution paths based on:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["The ",(0,s.jsx)(n.strong,{children:"content of the conversation"})," (from ",(0,s.jsx)(n.code,{children:"state.messages"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Custom State variables"})," updated by previous nodes"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"User inputs"})," or preferences"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Results of previous operations"})," or tool executions"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"For example, a Condition Node might check if the user has provided their contact information, if a certain product is in stock, or if a user's sentiment is positive or negative, and then direct the conversation flow accordingly."}),"\n",(0,s.jsx)(n.h2,{id:"inputs",children:"Inputs"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{}),(0,s.jsx)(n.th,{children:"Required"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"Condition Value"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.strong,{children:"Yes"})}),(0,s.jsxs)(n.td,{children:["A ",(0,s.jsx)(n.strong,{children:"JavaScript expression"})," that will be evaluated to determine which branch to follow. This expression should evaluate to either ",(0,s.jsx)(n.code,{children:"true"})," or ",(0,s.jsx)(n.code,{children:"false"}),"."]})]})})]}),"\n",(0,s.jsx)(n.h2,{id:"outputs",children:"Outputs"}),"\n",(0,s.jsx)(n.p,{children:"The Condition Node has two possible output connections:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"True:"})," This path is followed when the condition evaluates to ",(0,s.jsx)(n.code,{children:"true"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"False:"})," This path is followed when the condition evaluates to ",(0,s.jsx)(n.code,{children:"false"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"features",children:"Features"}),"\n",(0,s.jsx)(n.h3,{id:"javascript-expression-evaluation",children:"JavaScript Expression Evaluation"}),"\n",(0,s.jsx)(n.p,{children:"The Condition Node uses JavaScript expression evaluation to determine which path to take. This provides tremendous flexibility, allowing you to:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Access any part of the State"})," using dot notation (e.g., ",(0,s.jsx)(n.code,{children:"state.userDetails.age > 18"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Perform comparisons"})," using operators (",(0,s.jsx)(n.code,{children:"==="}),", ",(0,s.jsx)(n.code,{children:">"}),", ",(0,s.jsx)(n.code,{children:"<"}),", etc.)"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Use logical operators"})," for complex conditions (",(0,s.jsx)(n.code,{children:"&&"}),", ",(0,s.jsx)(n.code,{children:"||"}),", ",(0,s.jsx)(n.code,{children:"!"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Call JavaScript methods"})," on strings, arrays, or objects (e.g., ",(0,s.jsx)(n.code,{children:"state.products.some(p => p.category === 'Electronics')"}),")"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"dynamic-workflow-routing",children:"Dynamic Workflow Routing"}),"\n",(0,s.jsx)(n.p,{children:"The Condition Node enables dynamic routing of the conversation flow, creating personalized user experiences based on various factors:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"User preferences or characteristics"})," stored in the custom State"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Conversation context"})," derived from the messages array"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Exter
1nal data"})," retrieved by Tool Nodes"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Progress markers"})," indicating completion of specific steps"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"best-practices",children:"Best Practices"}),"\n","\n",(0,s.jsxs)(r.A,{children:[(0,s.jsxs)(a.default,{value:"pro-tips",label:"Pro Tips",children:[(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Clear condition naming"})}),(0,s.jsx)(n.p,{children:'Use descriptive names for your conditions (e.g., "If user is under 18, then Policy Advisor Agent", "If order is confirmed, then End Node") to make your workflow easier to understand and debug.'}),(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Prioritize simple conditions"})}),(0,s.jsx)(n.p,{children:"Start with simple conditions and gradually add complexity as needed. This makes your workflow more manageable and reduces the risk of errors."})]}),(0,s.jsxs)(a.default,{value:"pitfalls",label:"Potential Pitfalls",children:[(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Mismatched condition logic and workflow design"})}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Problem:"})," The conditions you define in the Condition Node don't align with the actual structure or purpose of your workflow, leading to unexpected or illogical conversation paths."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Example:"})," You create a condition that checks if the user's age is over 18, but the workflow doesn't collect age information in any preceding nodes, resulting in the condition always evaluating to ",(0,s.jsx)(n.code,{children:"false"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Solution:"}
1)," Ensure that the information needed for condition evaluation is collected or created in preceding nodes. Map out the data flow of your workflow to identify any missing links or incorrect assumptions."]}),"\n"]}),(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Overly complex condition expressions"})}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Problem:"})," The JavaScript expression used for the condition is too complex, making it difficult to understand, debug, or maintain."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Example:"})," You write a multi-line nested condition with complex object traversals, array filters, and multiple logical operators, making it almost impossible to predict its behavior in all scenarios."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Solution:"})," Break down complex conditions into simpler parts, potentially using multiple Condition Nodes in sequence. Consider moving complex logic to an LLM Node or Agent Node that can simplify the evaluation criteria and update the State accordingly."]}),"\n"]}),(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Undefined or null value handling"})}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Problem:"})," The condition doesn't account for undefined or null values, leading to unexpected or default behaviors."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Example:"})," Your condition checks ",(0,s.jsx)(n.code,{children:"state.userPreference.color === 'blue'"})," without first verifying if ",(0,s.jsx)(n.code,{children:"state.userPreference"})," exists, potentially causing an error."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Solution:"})," Include checks for undefined or null values in your conditions, or ensure that all necessary State properties are initialized with default values before they're accessed. For example: ",(0,s.jsx)(n.code,{children:"state.userPreference && state.userPreference.color === 'blue'"}),"."]}),"\n"]})]})]})]})}function p(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},51580:(e,n,t)=>{t.d(n,{A:()=>p});var i=t(22155),s=t(70851),o=t(2910),r=t(11069),a=t(82889);const l={tabList:"tabList_eqjL",tabItem:"tabItem_aml6"};var d=t(65723);function c({className:e,block:n,selectedValue:t,selectValue:i,tabValues:r}){const a=[],{blockElementScrollPositionUntilNextRender:c}=(0,o.a_)(),u=e=>{const n=e.currentTarget,s=a.indexOf(n),o=r[s].value;o!==t&&(c(n),i(o))},h=e=>{let n=null;switch(e.key){case"Enter":u(e);break;case"ArrowRight":{const t=a.indexOf(e.currentTarget)+1;n=a[t]??a[0];break}case"ArrowLeft":{const t=a.indexOf(e.currentTarget)-1;n=a[t]??a[a.length-1];break}}n?.focus()};return(0,d.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,s.A)("tabs",{"tabs--block":n},e),children:r.map(({value:e,label:n,attributes:i})=>(0,d.jsx)("li",{role:"tab",tabIndex:t===e?0:-1,"aria-selected":t===e,ref:e=>{a.push(e)},onKeyDown:h,onClick:u,...i,className:(0,s.A)("tabs__item",l.tabItem,i?.className,{"tabs__item--active":t===e}),children:n??e},e))})}function u({lazy:e,children:n,selectedValue:t}){const o=(Array.isArray(n)?n:[n]).filter(Boolean);if(e){const e=o.find(e=>e.props.value===t);return e?(0,i.cloneElement)(e,{className:(0,s.A)("margin-top--md",e.props.className)}):null}return(0,d.jsx)("div",{className:"margin-top--md",children:o.map((e,n)=>(0,i.cloneElement)(e,{key:n,hidden:e.props.value!==t}))})}function h(e){const n=(0,r.u)(e);return(0,d.jsxs)("div",{className:(0,s.A)("tabs-container",l.tabList),
1children:[(0,d.jsx)(c,{...n,...e}),(0,d.jsx)(u,{...n,...e})]})}function p(e){const n=(0,a.default)();return(0,d.jsx)(h,{...e,children:(0,r.v)(e.children)},String(n))}},72474:(e,n,t)=>{t.r(n),t.d(n,{default:()=>r});t(22155);var i=t(70851);const s={tabItem:"tabItem_U_yJ"};var o=t(65723);function r({children:e,hidden:n,className:t}){return(0,o.jsx)("div",{role:"tabpanel",className:(0,i.A)(s.tabItem,t),hidden:n,children:e})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.