Skip to content

[SUPPORT] how to work with eko.generate and eko.execute? #217

@sand1219

Description

@sand1219

Topic

How to work with or execute a pre-generated workflow?

Details

import { Eko } from "@eko-ai/eko";
import { BrowserAgent, FileAgent } from "@eko-ai/eko-nodejs";
import fs from 'fs/promises';

const llms = {
  default: {
    provider: "google",
    model: "gemini-2.0-flash",
    apiKey: "MYKEY" // replace with your real API key
  }
};

async function run() {
 
  const agents = [new BrowserAgent(), new FileAgent()];
  const eko = new Eko({ llms, agents });

  const browserAgent = new BrowserAgent();
  const fileAgent = new FileAgent();

# first 
const prompt = '....'
const plan = await eko.generate(prompt);
await fs.writeFile('workflow.json', JSON.stringify(plan, null, 2), 'utf-8');
console.log("Workflow saved to workflow.json");

# and then 

const workflowData = await fs.readFile('workflow.json', 'utf-8');
const myWorkflow = JSON.parse(workflowData);
const result = await eko.execute(myWorkflow);

# but it always throws
# Error: The task does not exist

}

run().catch(console.error);

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions