Skip to content

Support research mode flag in dynamic pathways#442

Merged
jmacAJ merged 1 commit intomainfrom
hammads_dynamic_pathway_research_mode
Jan 7, 2026
Merged

Support research mode flag in dynamic pathways#442
jmacAJ merged 1 commit intomainfrom
hammads_dynamic_pathway_research_mode

Conversation

@hammadsaj
Copy link
Copy Markdown
Collaborator

This lets us publish pathways that invoke research mode. This is done using the researchMode flag.

This pull request introduces support for a new optional researchMode property in the pathway execution flow, ensuring that it is preserved and passed through all relevant layers of the system. The changes ensure that researchMode is included in the prompt structure, GraphQL schema, and execution logic, allowing downstream components to leverage this flag as needed.

Support for researchMode property:

  • Updated the Prompt GraphQL type definition to include an optional researchMode Boolean property, allowing clients to specify this flag when constructing prompts.
  • Modified the PathwayManager to extract researchMode from prompt items, preserve it when building prompt objects, and include it in the prompt if present. [1] [2]

Pathway execution enhancements:

  • Updated the pathway execution logic in executeWorkspace.js to extract researchMode from the original prompt and include it in the arguments passed to the Cortex pathway, ensuring the flag is available during execution. [1] [2]

This lets us publish pathways that invoke research mode. This is done using the `researchMode` flag
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for a new optional researchMode boolean flag that can be specified in dynamic pathway definitions. The flag flows through the pathway creation, storage, and execution layers to enable research mode functionality in downstream pathway execution (specifically run_workspace_agent which invokes sys_entity_agent).

Key changes:

  • Added researchMode as an optional boolean field in the GraphQL PromptInput schema
  • Implemented extraction and preservation of researchMode in PathwayManager's prompt object creation logic
  • Modified executeWorkspace to extract researchMode from the original prompt and pass it to cortex pathways, with a default value of false when not provided

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/pathwayManager.js Adds researchMode to GraphQL PromptInput schema and implements extraction/preservation logic in _createPromptObject method
server/executeWorkspace.js Extracts researchMode from originalPrompt and includes it in cortexArgs for run_workspace_agent pathway, with a default of false
Comments suppressed due to low confidence (1)

server/executeWorkspace.js:145

  • The researchMode extraction and defaulting logic for run_workspace_agent is not covered by tests. Given that this repository has comprehensive test coverage for cortex pathway argument transformation (see tests/unit/graphql_executeWorkspace_transformation.test.js), tests should be added to verify:
  1. researchMode is correctly extracted from originalPrompt and added to cortexArgs
  2. researchMode defaults to false when not provided in originalPrompt
  3. researchMode from pathwayArgs is respected when already present

This is particularly important since line 104's comment mentions checking "if not already in pathwayArgs", but the current implementation doesn't actually check this condition.

            // Extract researchMode from originalPrompt if not already in pathwayArgs
            // originalPrompt could be the original object from JSON or a transformed Prompt object
            if (originalPrompt && typeof originalPrompt === 'object' && originalPrompt.researchMode !== undefined) {
                cortexArgs.researchMode = originalPrompt.researchMode;
            }
            
            // Transform context parameters to agentContext array format (only if agentContext not already provided)
            if (!cortexArgs.agentContext && (cortexArgs.contextId || cortexArgs.contextKey || cortexArgs.altContextId || cortexArgs.altContextKey)) {
                const agentContext = [];
                
                // Add primary context if present
                if (cortexArgs.contextId) {
                    agentContext.push({
                        contextId: cortexArgs.contextId,
                        contextKey: cortexArgs.contextKey || null,
                        default: true
                    });
                }
                
                // Add alternate context if present
                if (cortexArgs.altContextId) {
                    agentContext.push({
                        contextId: cortexArgs.altContextId,
                        contextKey: cortexArgs.altContextKey || null,
                        default: false
                    });
                }
                
                // If we have at least one context, set agentContext and remove old params
                if (agentContext.length > 0) {
                    cortexArgs.agentContext = agentContext;
                    delete cortexArgs.contextId;
                    delete cortexArgs.contextKey;
                    delete cortexArgs.altContextId;
                    delete cortexArgs.altContextKey;
                }
            }
            
            // Ensure researchMode defaults to false if not provided
            if (cortexArgs.researchMode === undefined) {
                cortexArgs.researchMode = false;
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Extract researchMode from originalPrompt if not already in pathwayArgs
// originalPrompt could be the original object from JSON or a transformed Prompt object
if (originalPrompt && typeof originalPrompt === 'object' && originalPrompt.researchMode !== undefined) {
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "if not already in pathwayArgs", but the code unconditionally overwrites cortexArgs.researchMode without checking if it already exists. This is inconsistent with how agentContext is handled on line 111, where it explicitly checks !cortexArgs.agentContext before setting it.

Consider checking if researchMode already exists in cortexArgs before extracting it from originalPrompt to avoid unexpectedly overwriting a value that was already provided in the pathway arguments. The logic should respect an explicitly provided value in pathwayArgs over the one from originalPrompt.

Suggested change
if (originalPrompt && typeof originalPrompt === 'object' && originalPrompt.researchMode !== undefined) {
if (
cortexArgs.researchMode === undefined &&
originalPrompt &&
typeof originalPrompt === 'object' &&
originalPrompt.researchMode !== undefined
) {

Copilot uses AI. Check for mistakes.
prompt: String!
files: [String!]
cortexPathwayName: String
researchMode: Boolean
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The researchMode property is being added to PromptInput, which is used for creating/updating pathways via the GraphQL mutation. However, there is no corresponding researchMode field in the Pathway output type (lines 481-484).

While this may be intentional if researchMode is only needed at creation time and not for querying, consider whether API consumers might need to retrieve this property when fetching pathway information. If pathways can be queried, the researchMode flag should likely be included in the output type for consistency.

Copilot uses AI. Check for mistakes.
@jmacAJ jmacAJ merged commit 72e72f6 into main Jan 7, 2026
6 checks passed
@jmacAJ jmacAJ deleted the hammads_dynamic_pathway_research_mode branch January 7, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants