```ts
export function doseTotals(log: [string, string][]): Record<string, string> {
  const totalMap: Record<string, number> = {};

  for (const [reagent, amount] of log) {
    if (!/^-?\d+(\.\d{1,3})?$/.test(amount)) {
      throw new Error(`Invalid amount format: ${amount}`);
    }

    const amountValue = parseFloat(amount);
    totalMap[reagent] = (totalMap[reagent] || 0) + amountValue;
  }

  for (const reagent in totalMap) {
    totalMap[reagent] = Math.round(totalMap[reagent] * 1000) / 1000;
  }

  return Object.fromEntries(
    Object.entries(totalMap).map(([reagent, total]) => [
      reagent,
      total.toFixed(total % 1 === 0 ? 0 : total.toString().split('.')[1].length)
    ])
  );
}
```