Supplier and Process Quality Audit for Active Pharmaceutical Ingredient and Pharmaceutical Intermediate Manufacturing: Tool Calling and Plugins

Data for this category comes from registered process documents, raw material batch ledgers, DCS control systems, weighing systems, LIMS laboratory

What data for this category looks like

Data for this category comes from registered process documents, raw material batch ledgers, DCS control systems, weighing systems, LIMS laboratory information management systems, chromatography data systems, and QMS quality management systems. Daily generated records include batch production records, material balance ledgers, reaction and purification step records, cleaning validation records, impurity profile reports, and deviation and change documents. Data updates per production batch and per process step. It includes fields such as step number, batch unique identifier, process parameter values, impurity test results, and yield statistics. There is no fixed unified single file size. File size changes dynamically with the production scale of the batch.

What constraints these characteristics impose on tool calling and plugins

Multiple heterogeneous data sources require plugins to support API integration with different systems. Plugins must adapt to interface formats of different protocols, including DCS, LIMS, and chromatography data systems. High-frequency updates per batch and step require tool calling triggers to tie to production steps. This avoids repeated pulling of expired data. Differences in structural complexity between impurity profile and deviation documents require plugins to parse non-standard laboratory test documents and compliance files. Audits of multi-step reactions require linking data across multiple process steps. Tool calling must support pulling associated data in step order, to ensure audit logic matches production flow. Cross-departmental quality audit workflows require tool calling results to sync to the QMS system. Complete calling logs must be retained for compliance traceability.

How to set the configurations

Configuration ItemRecommended SettingRationale
Workflow/API tool selectionautoAdapts to different scenarios of supplier audit and process step audit, automatically determines whether to call external tools to pull compliance and production data
Workflow/API function-call configurationBind to process step nodesMatches the feature of production updates per step, ensures tool calling timing synchronizes with process execution, and avoids redundant triggers
Tool call timeout duration600 secondsAdapts to response delays of LIMS and chromatography data systems, prevents audit workflow interruptions caused by slow system responses
Maximum number of tool return data entriesFirst 12 batch recordsMatches the data scale of single-batch audits, avoids loading excessive redundant data that affects audit efficiency
Context window size12000 tokenSupports audit data linked to multi-step reactions, covers complete process step logs and associated files
Tool call log archiving ruleStore by production batchMeets compliance traceability requirements, facilitates retrieval of calling records for corresponding batches during subsequent quality audits

Three common errors

  • Symptom: After deployment, the connection configuration option for custom code running tools cannot be found in the plugin configuration interface. Only other general tool options appear on the interface. Cause: The plugin registration process for code running tools was not enabled in FastGPT v4.17.0, or the plugin directory was not mounted correctly.
  • Symptom: A 504 timeout error occurs during tool calls, or empty test data is returned. Cause: The tool call timeout duration was set too short. It did not adapt to the actual response delays of LIMS and chromatography data systems, causing data pulling to terminate before completion.
  • Symptom: After streaming data transmission is interrupted, the front-end page stays at the content from the interruption moment. No retry or recovery mechanism is triggered. Cause: Resumable upload logic for tool calls was not configured, or the intermediate service did not correctly handle interrupt reconnection requests for streaming data.

How to confirm the configuration is correct

  • Initiate a simulated supplier audit tool call. Check whether raw material supplier qualification documents and test reports for the specified batch can be pulled correctly. Verify that returned data matches the data source.
  • Trigger a tool call for a process step. Confirm that call logs are archived to the specified storage path by production batch. Ensure logs include complete call parameters and returned results.
  • Adjust the tool call timeout duration value. Verify call success rates across different delay scenarios. Confirm the threshold adapts to the response speed of corresponding systems.
  • Check whether the configurations of toolChoice and functionCall take effect. Confirm that the tool calling mode and trigger timing meet preset audit process requirements.

The values provided here are common starting points, and should be evaluated against the reader's own samples.