Need Help with Coda Pack Timeout Issues

Hello,

I’m using the Gemini 1.5 pro AI Pack in Coda for a project that requires handling a significant amount of data (up to 1 million tokens). However, I’m encountering timeouts because the pack takes too long to respond.

With the current Gems Pack, the extended processing time leads to failures. Is there a workaround or a setting that allows the pack to have a longer timeout period? If not, is it feasible to create a custom pack that can bypass this limitation?

If anyone has experience with this or can offer a solution, please let me know.

Thanks,

Joaquín

Hi @Joaquin_Carminio - Unfortunately all Pack executions have a strict 1 minute timeout, which can’t be increased for a given doc or Pack. It may be possible to change how the Pack works to allow for asynchronous processing, but the Pack maker would need to make those changes. Specifically, they could have one button that initiates a query and outputs an ID, and another button that takes in the ID and checks for the result.

1 Like

Hi @Eric_Koleda ,

Thanks for the insight into how Pack execution timeouts currently work. It’s unfortunate that the 1 minute limit can’t be adjusted on a per-doc or per-Pack basis.

Can you point me to any specific documentation, code samples or examples that demonstrate how to best implement something like this? I’m somewhat new to Coda Pack development, so any concrete guidance or resources you can share would be much appreciated.

Thanks again for the thoughtful reply and advice!

Best,
Joaquin

Hi @Joaquin_Carminio - I don’t have an existing sample laying around, but here’s something I cooked up quickly:

import * as coda from "@codahq/packs-sdk";
export const pack = coda.newPack();

pack.addNetworkDomain("example.com");

pack.addFormula({
  name: "StartJob",
  description: "Starts a job, and returns an ID to track it.",
  parameters: [
    // TODO: Add parameters.
  ],
  resultType: coda.ValueType.String,
  isAction: true,
  execute: async function (args, context) {
    // TODO: Make a request to start the job, and return the job ID.
    // Returning a random ID in this example.
    let jobId = Math.random().toString(36).substring(2);
    return jobId;
  },
});

pack.addFormula({
  name: "CheckJob",
  description: "Checks if the job is complete.",
  parameters: [
    coda.makeParameter({
      type: coda.ParameterType.String,
      name: "jobId",
      description: "The ID of the job.",
    }),
  ],
  resultType: coda.ValueType.String,
  isAction: true,
  execute: async function (args, context) {
    let [jobId] = args;
    // TODO: Make a request to check if the job is finished.
    // Flipping a coin in this example.
    let isComplete = Math.random() > 0.5;
    let result;
    if (isComplete) {
      // TODO: Collect the result of the job.
      result = {
        message: "Hello world!",
        status: "complete",
      };
    } else {
      // Generate a value indicating that it's pending.
      result = {
        status: "pending"
      };
    }
    // Return the result as JSON.
    return JSON.stringify(result);
  },
});

// Define a schema for the result object.
const ResultSchema = coda.makeObjectSchema({
  properties: {
    status: { type: coda.ValueType.String },
    message: { type: coda.ValueType.String },
  },
  displayProperty: "status",
});

pack.addFormula({
  name: "FormatResult",
  description: "Formats a result.",
  parameters: [
    coda.makeParameter({
      type: coda.ParameterType.String,
      name: "resultJSON",
      description: "The JSON of the result.",
    }),
  ],
  resultType: coda.ValueType.Object,
  schema: ResultSchema,
  execute: async function (args, context) {
    let [resultJSON] = args;
    // Just parse the SON and return the object.
    return JSON.parse(resultJSON);
  },
});

pack.addColumnFormat({
  name: "FormatResult",
  instructions: "Formats a result.",
  formulaName: "FormatResult",
});

You would then setup a table with:

  1. The “Start Job” button that outputs to a “Job ID” column.
  2. A “Check Job” button, that takes the Job ID value as input, and writes to a “Results” column.
  3. The “Format Result” column format applied to the “Results” column.

You would push the first button to kick off the job. Then you would press the “Check Job” button to see if it’s complete and if so get the results. The results would be formatted using the column format so that you can use the Coda formula language to access the different fields.

Let me know if that helps!

1 Like